Skip to content

simongong/node-sqlizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node-Sqlizer

npm version

Node-Sqlizer is a helper to generate complex sql query statement.

Originally inspired by functions in Toshihiko.

Install

$ npm install --save node-sqlizer

API

API Doc

Example

let query = {
  table: 'test',
  where: {
    key1: 'value1',
    key2: {
      $or: {
        $neq: 'value2',
        $in: [2, 3, 4],
      },
    },
    key3: {
      $like: '%test%',
    },
  },
  limit: [10, 20],
  orderBy: 'key1 DESC',
};
let sqlizedQuery = Sqlizer.getSql(query);
// sqlizedQuery will be
// 'SELECT * FROM `test` WHERE (`key1` = "value1" AND ((`key2` != "value2" OR `key2` IN (2, 3, 4))) AND (`key3` LIKE "%test%")) ORDER BY key1 DESC LIMIT 10, 20'

License

MIT

About

A helper to generate complex sql query statement

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published