sql-light
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

sql-light

A simple SQLite query builder.

Example using Bun SQLite:

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

Readme

Keywords

none

Package Sidebar

Install

npm i sql-light

Weekly Downloads

3

Version

1.0.6

License

none

Unpacked Size

5.51 kB

Total Files

7

Last publish

Collaborators

  • reve-node