Registry / database / lx-mongodb

lx-mongodb

JSON →
library0.7.0jsnpmunverified

lx-mongodb is a MongoDB driver wrapper by Litixsoft, built on top of mongojs, providing a repository pattern, JSON schema validation, and a simple data access layer. Version 0.7.0 is the latest (and possibly final) release, with low maintenance frequency. It offers BaseRepo for CRUD operations, schema-based validation, and connection management via GetDb. Unlike Mongoose, it is lighter and uses mongojs internally, but has limited community support and documentation only in German.

npm install lx-mongodb
INSTALL
IMPORT
SIG · LX-MONGODB
L
lx-mongodb
databasejavascriptv0.7.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.

lxDb
const lxDb = require('lx-mongodb');
import lxDb from 'lx-mongodb';
Package uses CommonJS; ES modules not supported.
GetDb
const db = lxDb.GetDb('connectionString', ['collections']);
const db = lxDb.GetDb({url: '...', collections: [...]});
First argument is a connection string, second is an array of collection names.
BaseRepo
const repo = lxDb.BaseRepo(collection);
const repo = new lxDb.BaseRepo(collection);
BaseRepo is a factory function, not a constructor. Optionally accepts a schema function as second parameter.

Connects to a local MongoDB blog database, creates a repository for the users collection, inserts a user, and retrieves all users.

const lxDb = require('lx-mongodb'); const db = lxDb.GetDb('localhost/blog?w=1&journal=True&fsync=True', ['users']); const repo = lxDb.BaseRepo(db.users); // insert a user repo.insert({ userName: 'Alice', age: 30 }, (err, result) => { if (err) console.error(err); else console.log('Inserted:', result); }); // find all users repo.find((err, users) => { if (err) console.error(err); else console.log('Users:', users); });
Debug
Known issues
breakingMethod `insert` returns the raw mongojs result object, not a Mongoose-like document.
fix
Access inserted document from the callback result (e.g., result.ops[0]) or use `insertOne`.
affects: *
gotchaConnection string must include query parameters for write concern (e.g., ?w=1). Without them, writes may be unacknowledged.
fix
Always append ?w=1&journal=True to the connection string for safe writes.
affects: *
deprecatedPackage relies on `mongojs`, which is no longer actively maintained. Consider migrating to the official MongoDB Node.js driver or Mongoose.
fix
Replace lx-mongodb with `mongodb` or `mongoose` for modern applications.
affects: *
gotchaCollection names passed to GetDb are case-sensitive and must match exactly.
fix
Ensure collection names are spelled correctly and match the database.
affects: *
Errors
Common errors & fixes
Cannot find module 'mongojs'
lx-mongodb requires mongojs as a peer dependency, but it's not installed.
fix
npm install mongojs
TypeError: lxDb.GetDb is not a function
Incorrect import or package not loaded properly.
fix
Use const lxDb = require('lx-mongodb');
Error: schema is not a function
Second argument to BaseRepo must be a function returning a schema object.
fix
Ensure schema is defined as function() { return { ... }; }
MongoError: not authorized for query on blog.users
Authentication not provided or credentials missing.
fix
Include credentials in connection string: 'username:password@localhost/blog'
Upgrade
Version history
0.7.0latest on npm
Audit
Dependencies
mongojsrequiredUnderlying MongoDB driver used for all database operations
Agent activity
4 hits · last 30 days
node
4
Resources
lx-mongodb — npm install lx-mongodb · libregistry