Registry / testing / sworm-schema

sworm-schema

JSON →
library1.2.2jsnpmunverified

Schema utilities for testing databases with SWORM ORM. Current stable version is 1.2.2. It automates creating, deleting, and cleaning test databases, and can validate schema compatibility with queries. Designed for testing workflows, tightly integrated with SWORM (peer dependency ^3.7). Release cadence is low, primarily maintenance.

npm install sworm-schema
INSTALL
IMPORT
SIG · SWORM-SCHEMA
S
sworm-schema
testingjavascriptv1.2.2
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.

SwormSchema
✓ const { SwormSchema } = require('sworm-schema')
✗ import { SwormSchema } from 'sworm-schema'
Package is CommonJS only; named export via destructuring. No default export. ESM import will fail.
SwormSchema (default import mistake)
✓ const { SwormSchema } = require('sworm-schema')
✗ const SwormSchema = require('sworm-schema')
Common mistake: treating it as default export. SwormSchema is not a default export; you must destructure.
Constructor usage
✓ const { SwormSchema } = require('sworm-schema'); const schema = new SwormSchema({ url: 'sqlite:test.db', schema: { ... } })
✗ const schema = new SwormSchema()
Constructor requires both 'url' and 'schema' options. Missing required options will throw.

Creates an in-memory SQLite database from a schema definition, inserts a record, queries it, then cleans and drops the database.

const { SwormSchema } = require('sworm-schema'); const swormSchema = new SwormSchema({ url: 'sqlite:test/db/test.db', schema: { people: { id: { type: 'integer' }, name: { type: 'text' }, }, places: { id: { type: 'integer' }, name: { type: 'text' }, }, }, }); async function run() { await swormSchema.create(); const db = await swormSchema.connect(); const person = db.model({ table: 'people' }); await person({ id: 1, name: 'Alice' }).save(); console.log(await db.query('select * from people')); await swormSchema.clean(); await swormSchema.drop(); } run().catch(console.error);
Debug
Known issues
gotchaSwormSchema is not a default export; you must destructure from the require.
fix
Use const { SwormSchema } = require('sworm-schema') instead of const SwormSchema = require('sworm-schema').
affects: >=1.0.0
gotchaThe 'url' option must be a valid database connection string supported by SWORM. Incorrect strings may cause silent failures.
fix
Ensure the URL is compatible with SWORM (e.g., sqlite:path, mysql://...). See SWORM docs for valid formats.
affects: >=1.0.0
deprecatedSWORM itself may be in maintenance mode; check sworm package status for long-term stability.
fix
Consider alternative ORMs if active development is needed.
affects: >=1.0.0
gotchaThe 'schema' option columns must include 'type'. Omitting type may cause validation errors.
fix
Always specify a type property for each column, e.g., id: { type: 'integer' }.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: SwormSchema is not a constructor
Importing SwormSchema as default instead of named export.
fix
const { SwormSchema } = require('sworm-schema')
Cannot read property 'connect' of undefined
SwormSchema instance not properly created or async methods called without await.
fix
Ensure new SwormSchema() is called with correct options and all methods are awaited.
Error: Invalid schema definition: missing type for column 'id'
Column definition in schema object lacks 'type' property.
fix
Add type to each column, e.g., id: { type: 'integer' }.
Error: sworm is not a function
SWORM peer dependency missing or incompatible version.
fix
Install sworm@^3.7 as a peer dependency.
Upgrade
Version history
1.2.2latest on npm
Audit
Dependencies
swormrequiredPeer dependency required at runtime for database connections and query execution.
Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources
sworm-schema — npm install sworm-schema · libregistry