Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andrejewski/querie
SQL query builder
https://github.com/andrejewski/querie
query-builder sql
Last synced: 12 days ago
JSON representation
SQL query builder
- Host: GitHub
- URL: https://github.com/andrejewski/querie
- Owner: andrejewski
- License: mit
- Created: 2018-07-15T03:05:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-04-08T06:49:49.000Z (over 5 years ago)
- Last Synced: 2024-10-29T04:46:50.026Z (21 days ago)
- Topics: query-builder, sql
- Language: JavaScript
- Size: 16.6 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Querie
> SQL query builderConstruct queries to pass to [`node-postgres`](https://github.com/brianc/node-postgres) [`query()`](https://node-postgres.com/features/queries).
This library uses [`sql-template-strings`](https://github.com/felixfbecker/node-sql-template-strings) to build query statement objects.
## Example
```js
import { createQuery } from 'querie'const bluePeopleInsert = createQuery({
kind: 'insert',
table: 'people',
values: [
{ name: 'Chris', color: 'blue' },
{ name: 'Kevin', color: 'blue' }
]
})
// => insert into people (name, color) values ('Chris', 'blue'), ('Kevin', 'blue')const bluePeopleSelect = createQuery({
kind: 'select',
table: 'people',
columns: ['name', 'age'],
where: {
color: ['=', 'blue']
}
})
// => select name, age from people where color = 'blue'const bluePeopleUpdate = createQuery({
kind: 'update',
table: 'people',
set: {
color: 'green'
},
where: {
color: ['=', 'blue']
}
})
// => update people set color = 'green' where color = 'blue'
```## Features
- **State and side-effect free query building.**
Queries are built without knowledge of or connection to a database.- **Data driven queries**
Queries are built using plain JavaScript data structures, no method chaining.- **Column aliases**
Alias JS friendly column names to what is in the database seamlessly.