mongo-sql
mongo-sql copied to clipboard
order in select query
https://github.com/goodybag/mongo-sql/blob/master/docs/query-helpers.md#helper-order
Here is documentation and there is written // select "users".* from "users" order by "order"."id" desc, "order"."name" asc { type: 'select' , table: 'users'
// Object syntax is the preferable way since it can automatically // quote your columns and add in the default table , order: { id: 'desc', name: 'asc' } , order: ['id desc', 'name asc'] , order: 'id desc' } but when I use order: { id: 'desc', name: 'asc' } it shows the error that "{ error: syntax error at or near "order". Then I tested orderBy: { id: 'desc', name: 'asc' } and it is working correctly.
Maybe I'm misunderstanding the question @bakhodir10, but when i try
{
type: 'select',
table: 'users',
order: { id: 'desc', name: 'asc' }
}
on the playground it results in
select "users".* from "users" order by "users"."id" desc, "users"."name" asc