https://github.com/aquapi/sql-light
SQLite query builder for ya smol project
https://github.com/aquapi/sql-light
Last synced: over 1 year ago
JSON representation
SQLite query builder for ya smol project
- Host: GitHub
- URL: https://github.com/aquapi/sql-light
- Owner: aquapi
- Created: 2024-01-29T15:03:44.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-31T07:11:54.000Z (over 2 years ago)
- Last Synced: 2025-01-14T01:34:07.557Z (over 1 year ago)
- Language: TypeScript
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `sql-light`
A simple SQLite query builder.
Example using Bun SQLite:
```ts
import sql from 'sql-light';
import db from './my-db.db' with { type: 'sqlite' };
// Create user table
const userTable = sql.table({
name: 'Users',
schema: {
name: 'text not null',
pass: 'text not null'
},
// Type hint here
primaryKeys: ['name']
});
// Run create table statement
db.run(userTable.init);
// Create a query
const selectUser = sql.query(`select ${userTable.col.pass} from ${userTable} where ${userTable.$name} = $name`);
// Feed to Bun query initializer
const query = db.query<{ pass: string }, typeof selectUser.infer>(selectUser);
```