Registry / database / mongorito

mongorito

JSON →
library3.0.4jsnpmunverified

Lightweight and flexible MongoDB ODM for Node.js apps based on Redux architecture. Current stable version is 3.0.4, with no recent updates (last release several years ago). It uses generators/async/await and provides a schema-free approach to data management, leveraging Redux for state management and middleware extensibility. Key differentiators: Redux-based internals allow custom reducers and middleware; schema-free; relies on plugins for extra functionality. Suitable for small to medium projects but may be abandoned.

npm install mongorito
INSTALL
IMPORT
SIG · MONGORITO
M
mongorito
databasejavascriptv3.0.4
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.

Database
const { Database } = require('mongorito')
import { Database } from 'mongorito'
Mongorito uses CommonJS; ES module import may not work without transpilation.
Model
const { Model } = require('mongorito')
const Model = require('mongorito').Model
This also works but destructuring is preferred.
ObjectId
const { ObjectId } = require('mongorito')
const ObjectId = require('mongodb').ObjectId
Mongorito re-exports ObjectId from the mongodb driver for convenience.

Connects to MongoDB, defines a model, saves a document, queries it, and deletes it.

const { Database, Model } = require('mongorito'); const db = new Database('localhost/mydb'); db.connect() .then(async () => { class User extends Model {} db.register(User); const user = new User({ name: 'John', age: 30 }); await user.save(); console.log('User saved:', user.get('_id')); const found = await User.findOne({ name: 'John' }); console.log('Found:', found.get('name')); await user.remove(); console.log('User removed'); await db.close(); }) .catch(err => console.error(err));
Debug
Known issues
gotchaModel.find() does not execute the query synchronously; it returns a promise.
fix
Use await or .then() to get results.
affects: >=1.0.0
deprecatedThe 'mongorito' package has not been updated since 2016 and is considered abandoned.
fix
Consider migrating to Mongoose or another maintained ODM.
affects: *
breakingIn version 3, set(key, value) replaces the entire object if key is a dot-separated path? Check docs.
fix
Use set() with full key path or use plugins for deep modification.
affects: 3.x
gotchaCalling db.register(Model) after saving documents may cause unexpected behavior.
fix
Register all models before any database operations.
affects: >=1.0.0
breakingObjectId must be explicitly imported from mongorito; not automatically converted.
fix
Use const { ObjectId } = require('mongorito') and pass to model fields.
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: db.connect is not a function
Database not instantiated correctly or old version without connect method.
fix
Ensure you are using the correct constructor: const db = new Database('connection_string'); db.connect();
ReferenceError: Model is not defined
Model not imported or used before definition.
fix
Import Model: const { Model } = require('mongorito'); and then extend it.
Error: MongoError: cannot use a session that has ended
Default connection tries to use sessions unsupported by older MongoDB versions.
fix
Upgrade MongoDB server or pass options: new Database(uri, { useNewUrlParser: true, useUnifiedTopology: true })
Upgrade
Version history
3.0.4latest on npm
Audit
Dependencies
mongodbrequiredNative MongoDB driver used for database operations
mqueryrequiredUsed for query building
Agent activity
4 hits · last 30 days
node
4
Resources
mongorito — npm install mongorito · libregistry