mongo-sql icon indicating copy to clipboard operation
mongo-sql copied to clipboard

order in select query

Open bakhodir10 opened this issue 7 years ago • 1 comments

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.

bakhodir10 avatar May 03 '17 09:05 bakhodir10

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

CvBlixen avatar Oct 24 '18 19:10 CvBlixen