sql

@motioneffector/sql

A lightweight TypeScript wrapper for SQL.js with migrations, persistence, and full type safety.

npm version license TypeScript

Features

Read the full manual →

Quick Start

import { createDatabase } from '@motioneffector/sql'

// Create a database with auto-persistence
const db = await createDatabase({
  persist: { key: 'my-app', storage: 'indexeddb' }
})

// Create a table
db.exec(`
  CREATE TABLE users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    email TEXT UNIQUE
  )
`)

// Insert and query data
db.run('INSERT INTO users (name, email) VALUES (?, ?)', ['Alice', 'alice@example.com'])

const user = db.get<{ id: number; name: string; email: string }>(
  'SELECT * FROM users WHERE id = ?',
  [1]
)

Testing & Validation

License

MIT © motioneffector