Registry / database / esix
library5.4.0jsnpmunverified

Esix is a type-safe MongoDB ORM for TypeScript and Node.js (v5.4.0, monthly releases). It provides an ActiveRecord-like interface with zero configuration: define models as TypeScript classes extending BaseModel, and get automatic CRUD, query builder with where/whereIn/orderBy/limit/skip, pagination, firstOrCreate, and relationship support (hasMany). Unlike Mongoose, it requires no schema definitions and ships TypeScript types natively. Requires Node >= 20, peer dependencies mongodb ^6.0.0 and mongo-mock ^4.0.0.

npm install esix
INSTALL
IMPORT
SIG · ESIX
E
esix
databasejavascriptv5.4.0
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.

BaseModel
✓ import { BaseModel } from 'esix'
✗ const BaseModel = require('esix').BaseModel
ESM-only since v5. Use named imports.
Model
✓ import { Model } from 'esix'
✗ import Model from 'esix'
Model is a named export, not default. Only BaseModel is available for class extension.
esix (default)
✓ import * as esix from 'esix'
✗ import esix from 'esix'
No default export as of v5. Use namespace import.

Shows defining a model class extending BaseModel, and performing create, find, update, query, and delete operations.

import { BaseModel } from 'esix'; class User extends BaseModel { public name = ''; public email = ''; public age = 0; public isActive = true; } async function main() { const dbUrl = process.env.DB_URL ?? 'mongodb://localhost:27017/myapp'; // Esix auto-connects using DB_URL env var process.env.DB_URL = dbUrl; // Create const user = await User.create({ name: 'Alice', email: 'alice@example.com', age: 28 }); console.log('Created user:', user.id); // Find by ID const found = await User.find(user.id); console.log('Found:', found?.name); // Update user.age = 29; await user.save(); // Query const activeUsers = await User.where('isActive', true).get(); console.log('Active users:', activeUsers.length); // Delete await user.delete(); } main().catch(console.error);
Debug
Known issues
breakingEsix v5 requires Node >= 20 and is ESM-only. CommonJS require() will not work.
fix
Use ES module imports or upgrade to Node >= 20.
affects: >=5.0.0
breakingBaseModel no longer has a default constructor with arguments. Models must be instantiated using static create() or firstOrCreate().
fix
Replace 'new User({...})' with 'await User.create({...})'.
affects: >=5.0.0
deprecatedThe where() method with a function callback is deprecated. Use object syntax or chained where calls.
fix
Use User.where({ isActive: true }).get() or User.where('isActive', true).get().
affects: >=5.2.0
gotchaIf DB_URL environment variable is not set, Esix throws at first database operation. No explicit connect() call needed.
fix
Set DB_URL environment variable before using any model methods, e.g., process.env.DB_URL = 'mongodb://...'.
affects: >=5.0.0
gotchaEsix does NOT support mongoose-style schema validation. All validation must be done manually.
fix
Add your own validation logic in model methods or before saving.
affects: >=5.0.0
deprecatedThe 'pluck' method now returns an array of values directly. In v4 it returned an array of objects.
fix
Use const titles = await Post.pluck('title'); // returns string[]
affects: >=5.0.0
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'esix'
Missing peer dependency 'mongodb' or 'mongo-mock'.
fix
Run 'npm install esix mongodb' (and optionally 'mongo-mock' for testing).
TypeError: Class extends value undefined is not a constructor or null
Using CommonJS require() with ESM-only package (v5+).
fix
Change to import statement: import { BaseModel } from 'esix'. Ensure package.json has 'type':'module' or use .mjs extension.
MongoParseError: Invalid connection string
DB_URL environment variable missing or malformed.
fix
Set a valid MongoDB connection string: export DB_URL=mongodb://localhost:27017/myapp
EsixError: Method create() must be called as static method
Trying to call create on an instance instead of the class.
fix
Use await User.create(...) not await user.create(...).
Upgrade
Version history
5.4.0latest on npm
Audit
Dependencies
mongodbrequiredMongoDB driver for database operations
mongo-mockoptionalMock MongoDB for testing
Agent activity
14 hits · last 30 days
node
12
Resources
packageesix ↗
esix — npm install esix · libregistry