Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/unlight/query-builder
https://github.com/unlight/query-builder
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/unlight/query-builder
- Owner: unlight
- Created: 2016-07-22T08:32:15.000Z (over 8 years ago)
- Default Branch: dev
- Last Pushed: 2017-04-02T16:28:36.000Z (over 7 years ago)
- Last Synced: 2024-10-05T22:04:40.558Z (about 1 month ago)
- Language: TypeScript
- Size: 30.3 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Query Builder
Builds sql query for RDBMS.## INSTALL
```
npm i -S @iamthes/query-builder
```## USAGE
```js
const queryBuilder = require("@iamthes/query-builder");
const q = queryBuilder.create("mysql");
var sql = q()
.select("*")
.from("user")
.where("id", 5)
.get(); // select * from user where id = 5
```
```js
const queryBuilder = require("@iamthes/query-builder");
const Builder = queryBuilder.mysql;
const b = new Builder();
var sql = b
.select("count", "*", "total")
.from("user")
.get(); // select count(*) as total from user// Using same instance to build next query.
sql = b
.select("job, salary")
.from("user")
.where("salary", "@null")
.get(); // select job, salary from user where salary = null
```
Check `test` directory for more examples.