{"id":42768,"library":"forj","title":"Forj - SQLite ORM and Query Builder","description":"Forj is a lightweight, dependency-free SQLite ORM and Query Builder for Node.js 18+. Version 0.1.11 supports schema migrations, query building, and an active record-like ORM pattern. Unlike heavier ORMs like Sequelize or Knex, Forj has zero dependencies and focuses on SQLite exclusively, making it ideal for embedded databases and serverless environments. It provides both a fluent query builder and a resource-based ORM with support for transactions, migrations, and model definitions. The package is released under the MIT license and follows semantic versioning.","status":"active","version":"0.1.11","language":"javascript","source_language":"en","source_url":"git://github.com/attla/forj","tags":["javascript","forj","attla","resources","support","sqlite","migration","schema","orm"],"install":[{"cmd":"npm install forj","lang":"bash","label":"npm"},{"cmd":"yarn add forj","lang":"bash","label":"yarn"},{"cmd":"pnpm add forj","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only since v0.1.0; no CommonJS support.","wrong":"const Forj = require('forj')","symbol":"Forj","correct":"import Forj from 'forj'"},{"note":"Named export; available in ESM only.","wrong":"const Schema = require('forj').Schema","symbol":"Schema","correct":"import { Schema } from 'forj'"},{"note":"Named export for ORM model definitions.","wrong":"const { Model } = require('forj')","symbol":"Model","correct":"import { Model } from 'forj'"},{"note":"Resource class for building CRUD APIs.","wrong":null,"symbol":"Resource","correct":"import { Resource } from 'forj'"}],"quickstart":{"code":"import Forj, { Schema, Model } from 'forj';\n\n// Initialize Forj with a database file\nconst forj = new Forj({ path: ':memory:', logging: false });\n\n// Define a schema\nconst userSchema = new Schema('users', {\n  id: { type: 'integer', primary: true, autoIncrement: true },\n  name: { type: 'text', notNull: true },\n  email: { type: 'text', unique: true },\n  age: { type: 'integer', default: 0 }\n});\n\n// Create the table (run once)\nawait forj.run(userSchema.create());\n\n// Define a model\nclass User extends Model {\n  static get schema() {\n    return userSchema;\n  }\n}\n\n// Insert a record\nconst user = new User({ name: 'Alice', email: 'alice@example.com', age: 30 });\nawait user.save();\n\n// Query using the query builder\nconst users = await forj.table('users').where('age', '>', 18).all();\nconsole.log(users);\n\n// Close connection\nawait forj.close();","lang":"typescript","description":"Demonstrates initializing Forj, defining a schema, creating a model, inserting a record, and querying with the builder."},"warnings":[{"fix":"Upgrade Node.js to version 18 or later.","message":"Forj requires Node.js >= 18.0.0 due to ESM support and native APIs.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Replace `forj.table('name')` with `forj.query('name')`.","message":"The `Forj.prototype.table()` method is deprecated since v0.1.10; use `Forj.prototype.query()` instead.","severity":"deprecated","affected_versions":">=0.1.10 <0.2.0"},{"fix":"Use only 'integer', 'text', 'real', 'blob', or 'numeric' as column types.","message":"Schema column type 'integer' is used for autoIncrement; using 'int' may cause unexpected behavior.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Check for successful save by catching errors or using Model.create() which returns the row.","message":"Model.save() returns undefined in v0.1.11; previous versions returned the inserted row.","severity":"breaking","affected_versions":"=0.1.11"},{"fix":"Move options like `autoIncrement: true` into the column definition object.","message":"The `Schema` constructor's third parameter (options) is deprecated; pass options as part of the column definition.","severity":"deprecated","affected_versions":">=0.1.5"}],"env_vars":null,"search_vec":"'0.1.11':23 '18':21 'activ':31 'attla':97 'base':73 'build':28 'builder':6,18,68 'databas':58 'definit':82 'depend':12,47 'dependency-fre':11 'embed':57 'environ':61 'exclus':52 'fluent':66 'focus':49 'follow':92 'forj':1,7,44,96 'free':13 'heavier':38 'ideal':55 'javascript':95 'knex':43 'licens':90 'lightweight':10 'like':34,40 'make':53 'migrat':26,79,101 'mit':89 'model':81 'node.js':20 'orm':3,15,35,39,74,103 'packag':84 'pattern':36 'provid':63 'queri':5,17,27,67 'record':33 'record-lik':32 'releas':86 'resourc':72,98 'resource-bas':71 'schema':25,102 'semant':93 'sequel':41 'serverless':60 'sqlite':2,14,51,100 'support':24,76,99 'transact':78 'unlik':37 'version':22,94 'zero':46","created_at":"2026-06-05T16:56:34.644133+00:00","updated_at":"2026-06-05T16:56:34.644133+00:00","problems":[{"fix":"Use `import` syntax or switch to dynamic import: `const Forj = (await import('forj')).default`.","cause":"Using CommonJS require() to import an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Use `forj.query('tableName')` instead.","cause":"Calling deprecated `table()` method after v0.1.10.","error":"TypeError: forj.table is not a function"},{"fix":"Use `schema.create({ ifNotExists: true })` or wrap in a try-catch.","cause":"Running schema.create() multiple times without checking for existing table.","error":"SQLITE_ERROR: table users already exists"},{"fix":"Change column type to 'text' (or 'integer', 'real', 'blob', 'numeric').","cause":"Using JavaScript types like 'string' instead of SQLite types.","error":"ForjError: Column type 'string' is not a valid SQLite type."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://zunq.dev","github":"git://github.com/attla/forj","docs":null,"changelog":null,"pypi":null,"npm":"forj","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}