Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Atscript

@atscript/db-sqlite

Define your models once — get TypeScript types, runtime validation, and DB metadata from a single .as model.

Documentation · SQLite Adapter


SQLite adapter for @atscript/db with a swappable driver architecture. Ships with a BetterSqlite3Driver for better-sqlite3 and supports custom drivers for node:sqlite (Node 22.5+), sql.js, or any other SQLite engine.

Installation

pnpm add @atscript/db-sqlite better-sqlite3

# Optional — enables @db.search.vector via the sqlite-vec extension:
pnpm add sqlite-vec

Quick Start

import { DbSpace } from "@atscript/db";
import { createAdapter } from "@atscript/db-sqlite";

const db = createAdapter("./myapp.db");
const users = db.getTable(UsersType);

await users.insertOne({ name: "John", email: "john@example.com" });

Features

  • Swappable driver via TSqliteDriver interface (5 methods)
  • Built-in BetterSqlite3Driver for immediate use (with optional { vector: true } and loadExtensions hooks)
  • MongoDB-style filter translation to parameterized SQL (no injection risk)
  • Automatic schema management from @db.* annotations
  • FTS5 full-text search support
  • Vector similarity search via sqlite-vecvec0 shadow tables with AI/AU/AD sync triggers, KNN with partition push-down, threshold control
  • Embedded object flattening and @db.json storage
  • Schema sync via @atscript/db/sync

Documentation

License

MIT