Registry / database / very-simple-orm

very-simple-orm

JSON →
library2.0.18jsnpmunverified

An ORM for TypeScript/JavaScript projects that generates SQL statements for MySQL and other databases, tested with MSSQL. Current version: 2.0.18. Unlike full-fledged ORMs, this library is driver-agnostic — it only produces SQL strings and value arrays, requiring users to pass them to their own database connection driver. It supports table creation, CRUD operations, JOINs, validations, and raw SQL. Release cadence is irregular; the package is not widely adopted. Key differentiators: lightweight, no database driver binding, TypeScript type generation from table schemas.

npm install very-simple-orm
INSTALL
IMPORT
SIG · VERY-SIMPLE-ORM
V
very-simple-orm
databasejavascriptv2.0.18
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.

Table
import { Table } from 'very-simple-orm'
const Table = require('very-simple-orm')
Use named import for ESM. CommonJS users must destructure: const { Table } = require('very-simple-orm'). Wrong require returns an object.
QueryBuilder
import { QueryBuilder } from 'very-simple-orm'
import QueryBuilder from 'very-simple-orm'
QueryBuilder is a named export, not default.
type TableSchema
import type { TableSchema } from 'very-simple-orm'
import { TableSchema } from 'very-simple-orm'
TableSchema is a TypeScript type, not a runtime value. Use import type to avoid errors.

Creates a table schema and generates a SELECT SQL statement with parameterized values.

import { Table, QueryBuilder } from 'very-simple-orm'; const userTable = new Table('users', [ { fieldName: 'id', type: { Number: 'Number', autoIncrement: true }, primaryKey: true, null: false }, { fieldName: 'email', type: { String: 'String', size: 200 }, unique: true, null: false } ]); // Generate SELECT SQL const { sql, values } = userTable.select( [{ fieldName: 'email', value: 'test@example.com', operator: '=', separator: 'NONE' }], ['*'], {}, 0, 10, [] ); console.log(sql); // SELECT * FROM users WHERE email = ? LIMIT 0,10 console.log(values); // ['test@example.com'] // Use with a database driver (e.g., mysql2) // const connection = require('mysql2/promise'); // await connection.execute(sql, values);
Debug
Known issues
gotchaThe library only generates SQL strings — it does not execute queries. You must pass the output to your own database driver.
fix
Always pass the returned { sql, values } to your database driver's execute/query method.
affects: >=0.0.0
gotchaProperty names are case-sensitive and must match exactly. 'PrimeryKey' is a typo in the library — use 'primaryKey' in some versions; check your version's documentation.
fix
Inspect the TableField interface: use 'primaryKey' instead of 'PrimeryKey' in newer versions. Always define fields with exact casing.
affects: >=1.0.0
breakingIn version 2.0.0, the select() method signature changed: the second parameter must be an array of field names, not a string. Old code passing a string will break.
fix
Update select() calls: pass ['field1', 'field2'] instead of 'field1, field2'.
affects: >=2.0.0
deprecatedThe use of 'AS_DEFINED' for default values is deprecated. Use the new 'default' object format with 'value' directly.
fix
Replace { 'AS_DEFINED': 'AS DEFINED', value: '...' } with { value: '...' } in field definitions.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: Cannot destructure property 'sql' of (intermediate value) as it is undefined.
Calling select() on a table that was not properly initialized (e.g., missing Table constructor arguments).
fix
Ensure you call  new Table('name', [...fields]) with both arguments. The table must have at least one field.
ReferenceError: require is not defined in ES module scope
Using CommonJS require() in an ESM project or environment.
fix
Use  import { Table } from 'very-simple-orm'  instead, or set { "type": "commonjs" } in your package.json.
Property 'createTable' does not exist on type 'Table'.
TypeScript strict mode: the Table type does not expose createTable() because it's not in the type definitions.
fix
Use a type assertion or cast to any: (table as any).createTable(). Better yet, use the QueryBuilder API for SQL generation.
Upgrade
Version history
2.0.18latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
18
Meta
1
OpenAI (training)
1
Resources
very-simple-orm — npm install very-simple-orm · libregistry