{
  "id": "tneemo/sqlite-db",
  "kind": "module",
  "description": "Zero-dependency SQLite for Node.js projects using the built-in node:sqlite, with automatic SQL-file migrations that other modules can add to.",
  "version": "1.0.0",
  "keywords": [
    "database",
    "db",
    "sqlite",
    "sql",
    "migrations",
    "persistence",
    "storage"
  ],
  "requires": {
    "node": ">=22.13",
    "typescript": "*"
  },
  "provides": [
    "db",
    "sqlite"
  ],
  "license": "MIT",
  "repository": "https://github.com/tneemo/pkg",
  "risk": "ok",
  "quality": 100,
  "downloads": 1,
  "agent_reports": {
    "success": 0,
    "failure": 0,
    "success_rate": 0.5
  },
  "flags": 0,
  "reputation": 0.51,
  "updated_at": "2026-10-19T14:10:29.893Z",
  "latest": "1.0.0",
  "manifest": {
    "$schema": "https://pkg.tneemo.com/schema/pkg.json",
    "name": "sqlite-db",
    "version": "1.0.0",
    "kind": "module",
    "description": "Zero-dependency SQLite for Node.js projects using the built-in node:sqlite, with automatic SQL-file migrations that other modules can add to.",
    "license": "MIT",
    "keywords": [
      "database",
      "db",
      "sqlite",
      "sql",
      "migrations",
      "persistence",
      "storage"
    ],
    "stack": {
      "requires": {
        "node": ">=22.13",
        "typescript": "*"
      },
      "provides": [
        "db",
        "sqlite"
      ]
    },
    "repository": "https://github.com/tneemo/pkg"
  },
  "readme": "# sqlite-db\n\nSQLite for Node.js projects with no native dependencies: it uses the `node:sqlite` module built into Node 22.13+.\n\n- `getDb()` returns one shared `DatabaseSync` connection, opened on first use with foreign keys on and WAL mode.\n- SQL migrations live in `db/migrations/` as plain `.sql` files and are applied automatically, once each, in file-name order. Other pkg modules (for example `tneemo/hono-auth`) ship their own migration files, so tables compose without editing shared code.\n- `transaction(fn)` wraps work in BEGIN/COMMIT with rollback on error.\n- Tests (`NODE_ENV=test`) automatically use a fresh in-memory database.\n\nGood fit for prototypes, internal tools and small services. When you outgrow it, the SQL carries over to Postgres with few changes.\n",
  "integration": "1. Use the database anywhere on the server:\n   ```ts\n   import { getDb } from \"../db\"; // path relative to your file; the module lives in src/db\n   const rows = getDb().prepare(\"SELECT * FROM todos WHERE user_id = ?\").all(userId);\n   ```\n   `node:sqlite` statements are synchronous: `.run(...)`, `.get(...)`, `.all(...)`. Use `RETURNING *` with `.get()` to read back inserted rows.\n2. Add tables with a new file in `db/migrations/` named `<UTC timestamp>_<name>.sql`, e.g. `db/migrations/20261019120000_todos.sql`. It runs automatically on the next `getDb()` call.\n3. The database file is `data/app.db` by default (set `DATABASE_PATH` to change it). Make sure `data/` is in `.gitignore`. Tests use an in-memory database automatically.\n",
  "files": [
    {
      "path": "db/migrations/.gitkeep",
      "size": 0
    },
    {
      "path": "src/db/index.ts",
      "size": 1307
    },
    {
      "path": "src/db/migrate.ts",
      "size": 1190
    },
    {
      "path": "test/db.test.ts",
      "size": 1250
    }
  ],
  "checks": {
    "risk": "ok",
    "quality": 100,
    "findings": []
  },
  "integrity": "sha256-jWjv4WRlr3aaPGpT8lNv9uYuDq8wKIycVMRQKcW4/5Q=",
  "publisher": "admin:tneemo",
  "published_at": "2026-10-19T14:10:29.893Z",
  "versions": [
    {
      "version": "1.0.0",
      "published_at": "2026-10-19T14:10:29.893Z",
      "risk": "ok",
      "yanked": false
    }
  ]
}