Registry / database / schema-seed-adapter-sqlite

schema-seed-adapter-sqlite

JSON →
library0.1.11jsnpmunverified

SQLite adapter for the schema-seed test data seeding library (v0.1.11). Automatically loaded by the schema-seed CLI when a SQLite connection string is provided. Enables SQLite database seeding with schema-seed's schema-driven approach. Released under active development with TypeScript type definitions. Key differentiator: built specifically for schema-seed's adapter-based architecture, simplifying SQLite integration compared to writing custom seeding logic with better-sqlite3 or sql.js.

npm install schema-seed-adapter-sqlite
INSTALL
IMPORT
SIG · SCHEMA-SEED-ADAPTE
S
schema-seed-adapter-sqlite
databasejavascriptv0.1.11
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SqliteAdapter
import { SqliteAdapter } from 'schema-seed-adapter-sqlite'
import SqliteAdapter from 'schema-seed-adapter-sqlite'
The adapter is a named export, not a default export.
SqliteAdapter
const { SqliteAdapter } = require('schema-seed-adapter-sqlite')
const SqliteAdapter = require('schema-seed-adapter-sqlite')
CommonJS require must destructure the named export.
SqliteAdapter
import type { SqliteAdapter } from 'schema-seed-adapter-sqlite'
import { SqliteAdapter } from 'schema-seed-adapter-sqlite' (when only type is needed)
For TypeScript type-only imports, use 'import type' to avoid bundling runtime code.

Creates an in-memory SQLite database, seeds 10 users with auto-incrementing IDs, first names, and emails using schema-seed.

import { Seeder } from 'schema-seed'; import { SqliteAdapter } from 'schema-seed-adapter-sqlite'; import Database from 'better-sqlite3'; const db = new Database(':memory:'); const adapter = new SqliteAdapter(db); const seeder = new Seeder(adapter, { users: { schema: { id: 'increment', name: 'first name', email: 'email', }, count: 10, }, }); await seeder.seed(); console.log('Seeded 10 users into SQLite in-memory database.');
Debug
Known issues
gotchaAdapter is only available as ESM; CommonJS require may fail if not using Node.js >= 12 or if the package does not have a proper CJS build. Check exports.
fix
Use ES modules (import) or set type: "module" in package.json.
affects: >=0.1.0
gotchaThe SqliteAdapter constructor expects a better-sqlite3 Database instance. Passing a sql.js or other driver will cause runtime errors.
fix
Use better-sqlite3 exclusively. Example: const Database = require('better-sqlite3'); const db = new Database(path);
affects: >=0.1.0
breakingIn version 0.1.0, the adapter exported as default export. This changed to named export in 0.1.1.
fix
Use named import: import { SqliteAdapter } from 'schema-seed-adapter-sqlite'
affects: >=0.1.1
Errors
Common errors & fixes
TypeError: SqliteAdapter is not a constructor
Using default import when only named export exists.
fix
Change import to: import { SqliteAdapter } from 'schema-seed-adapter-sqlite'
Error: Cannot find module 'better-sqlite3'
better-sqlite3 is a peer dependency and not installed automatically.
fix
Install better-sqlite3: npm install better-sqlite3
The 'SqliteAdapter' class does not have a 'seed' method.
Calling seed on adapter instance instead of Seeder instance.
fix
Use adapter with Seeder: const seeder = new Seeder(adapter, config); await seeder.seed();
TypeError: db.exec is not a function
Passing a sql.js database instance instead of better-sqlite3.
fix
Ensure you are using better-sqlite3: const Database = require('better-sqlite3'); const db = new Database(path);
Upgrade
Version history
0.1.11latest on npm
Audit
Dependencies
schema-seedrequiredCore library that provides CLIs and schema-based seeding. This adapter is used with schema-seed.
better-sqlite3requiredSQLite database driver used for database operations.
Agent activity
17 hits · last 30 days
node
14
Meta
2
Resources
schema-seed-adapter-sqlite — npm install schema-seed-adapter-sqlite · libregistry