An open API service indexing awesome lists of open source software.

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

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);
```