Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gvanderest/seaql
SQL Building Library
https://github.com/gvanderest/seaql
generator mysql postgres sql
Last synced: 8 days ago
JSON representation
SQL Building Library
- Host: GitHub
- URL: https://github.com/gvanderest/seaql
- Owner: gvanderest
- Created: 2018-10-18T02:27:15.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-18T05:34:50.000Z (about 6 years ago)
- Last Synced: 2024-12-17T08:11:10.816Z (17 days ago)
- Topics: generator, mysql, postgres, sql
- Language: TypeScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SeaQL
Library for generating some SQL, primarily targeting MySQL and Postgres databases.
## Installation
```shell
yarn add seaql
```## Examples
### Insert
```js
import { insert } from "seaql";const sql = insert({ firstName: "Guillaume", lastName: "VanderEst" }).into("customers").stringify();
# INSERT INTO customers (firstName, lastName) VALUES ('Guillaume', 'VanderEst');
```### Select
```js
import { select } from "seaql";const sql = select(["id"]).from("customers").where({ firstName: "Guillaume", lastName: "VanderEst" }).stringify();
# SELECT id FROM customers WHERE firstName = 'Guillaume' AND lastName = 'VanderEst';
```### Update
```js
import { update } from "seaql";const sql = update("customers").set({ firstName: "Edward", lastName: "Nigma" }).where({ id: 12345 }).stringify();
# UPDATE customers SET firstName = 'Edward', lastName = 'Nigma' WHERE id = 12345;
```### Delete
Alternatively, `del` can be used. As `delete` is a reserved JavaScript keyword.
```js
import { remove } from "seaql";const sql = remove("customers").where({ id: 12345 }).stringify();
# DELETE customers WHERE id = 12345;
```## Future
* Value escaping
* Validations for when some functions can be called
* Handling primitives vs arrays flexibly
* Table+Field combinations
* Field aliasing
* Joins
* Nested SeaQL subqueries
* Parsing from SQL
* Aggregate functions
* Nesting of OR and AND clauses using arrays/objects
* Limits
* Filtering
* Ordering
* Partitioning?
* Engine-specific optimizations
* Returning clauses
* Select with no fields provided performing *