bookshelf / bookshelf

A simple Node.js ORM for PostgreSQL, MySQL and SQLite3 built on top of Knex.js
http://bookshelfjs.org
MIT License
6.36k stars 573 forks source link

IN command in postgress #657

Closed Ashesh007 closed 9 years ago

Ashesh007 commented 9 years ago

how to use IN command in bookshelf?? kindly reply??

bendrucker commented 9 years ago

Currently there's support for where in. If that's not what you're looking for please share the SQL you'd like to generate.

http://knexjs.org/#Builder-whereIn

Ashesh007 commented 9 years ago

My sql query is like this

bookshelf.knex('wa_user') .select('id', 'name', 'phone_no') .whereIn('phone_no' , [ contacts ]) .then(function(userData) { //console.log(userData); callback(null, userData); })

and error shown like as follow

{ [error: function phone_no(bigint, bigint, integer, bigint, bigint, integer, bigint, bigint) does not exist] name: 'error', length: 260, severity: 'ERROR', code: '42883', detail: undefined, hint: 'No function matches the given name and argument types. You might need to add explicit type casts.', position: '54', internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'parse_func.c', line: '306', routine: 'ParseFuncOrColumn' }

bendrucker commented 9 years ago

Please format your code using the correct GitHub Flavored Markdown syntax in the future so we can read it.

I need a full example here, i.e. something that defines contacts so I can run it directly and generate a query string.