Registry / database / sqlar
library0.1.20jsnpmunverified

sqlar is an ORM for SQL databases at version 0.1.20, providing a TypeScript-first interface with type-safe query building and model mapping. It supports PostgreSQL, MySQL, SQLite, and others via a plugin architecture. Released frequently as a young project, it focuses on simplicity and type inference, differentiating from heavier ORMs like Sequelize or TypeORM. As of early 2025, it is in active development with breaking changes expected between minor versions.

npm install sqlar
INSTALL
IMPORT
SIG · SQLAR
S
sqlar
databasejavascriptv0.1.20
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.

sqlar
import sqlar from 'sqlar'
const sqlar = require('sqlar')
Default export; ESM-only package, CommonJS require not supported.
Model
import { Model } from 'sqlar'
Named export for defining models.
QueryBuilder
import { QueryBuilder } from 'sqlar'
Named export for building raw queries.

Shows basic setup with SQLite, defining a model, syncing schema, inserting a record, and querying all records.

import sqlar from 'sqlar'; import { Model } from 'sqlar'; const db = sqlar.connect({ type: 'sqlite', database: ':memory:', }); class User extends Model { static table = 'users'; } // Create table await db.sync(); // Insert const user = await User.create({ name: 'Alice', email: 'alice@example.com' }); // Query const users = await User.findAll(); console.log(users);
Debug
Known issues
breakingVersion 0.1.x changes model definition syntax.
fix
Update to use static class properties instead of decorators.
affects: >=0.1.0 <0.2.0
deprecated`sqlar.raw()` is deprecated; use `QueryBuilder` instead.
fix
Replace sqlar.raw with new QueryBuilder pattern.
affects: >=0.1.10
gotchaDefault export is ESM-only; CommonJS require will fail.
fix
Use import syntax or dynamic import; set type: module in package.json.
affects: >=0.1.0
gotchaTypeScript types are included but may lag behind releases.
fix
Check types match runtime version; use tslib if needed.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'sqlar' or its corresponding type declarations.
Missing TypeScript type definitions or incorrect module resolution.
fix
Install @types/sqlar if not bundled, or ensure tsconfig.json has 'moduleResolution': 'node' and 'esModuleInterop': true.
TypeError: sqlar.connect is not a function
CommonJS require() used instead of ESM import.
fix
Use import sqlar from 'sqlar' and ensure package.json has 'type': 'module'.
SQLITE_ERROR: no such table: users
Table not created because sync() was not called.
fix
Call await db.sync() before performing CRUD operations.
Upgrade
Version history
0.1.20latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
10
Meta
1
Amazon
1
OpenAI (training)
1
Resources
packagesqlar
sqlar — npm install sqlar · libregistry