node-querybuilder
Querybuilder have a simple, mongo like, API to create SQL and NoSQL queries.
Install
$ npm install querybuilder
Supported storages / client libs
- MongoDB (Tested with node-mongodb-native)
- MySQL (Tested with node-mysql)
API
Create NoSQL query (MongoDB)
var Querybuilder = ;var qb = 'mongodb'; // Synchronousvar query = qb ;/* <- returns: { type: 'select', what: undefined, where: { name: 'horst' }, limit: 50, skip: 5, sort: {}, set: {} }*/ // Asynchronous// Define a handler. We simply forward the query to the callbackqb; qb // just for campability to mysql ;
Create SQL query (MySQL)
var Querybuilder = ;var qb = 'mysql'; // Synchronousvar query = qb ;// <- returns: 'SELECT * FROM `users` WHERE (`name` = \'horst\') LIMIT 50,5' // Asynchronous// Define a handler. We simply forward the query to the callbackqb; qb ;
Module under MIT Licence