Registry / database / lucid-mongo

lucid-mongo

JSON →
library3.1.6jsnpmunverified

Lucid Mongo is a MongoDB ODM and query builder for Node.js, built on top of the AdonisJS Lucid ORM ecosystem. The current stable version is 3.1.6. It provides ES6 class-based models, hooks, associations, serializers, migrations, seeds, and factories, similar to @adonis/lucid but specifically for MongoDB. It can be used standalone or integrated with AdonisJS. Key differentiators include noSQL-native features, async/await support (v2+), and MongoDB operator syntax (v3+).

npm install lucid-mongo
INSTALL
IMPORT
SIG · LUCID-MONGO
L
lucid-mongo
databasejavascriptv3.1.6
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.

Model
import { Model } from 'lucid-mongo'
const { Model } = require('lucid-mongo')
CommonJS require works; ESM default import is available since v3.
Database
import { Database } from 'lucid-mongo'
const Database = require('lucid-mongo/src/Database')
Direct path imports are not supported; use package export.
LucidMongoProvider
import { LucidMongoProvider } from 'lucid-mongo/providers/LucidMongoProvider'
import LucidMongoProvider from 'lucid-mongo'
Provider must be imported from subpath.

Shows basic usage: import Model and Database, define a User model, configure MongoDB connection, and create a new document.

import { Model, Database, LucidMongoProvider } from 'lucid-mongo'; import { Config } from '@adonisjs/sink'; // Configure database connection const config = new Config(); config.set('database.mongodb', { client: 'mongodb', connectionString: process.env.DB_CONNECTION_STRING || 'mongodb://localhost:27017/myapp', connection: { host: process.env.DB_HOST || 'localhost', port: parseInt(process.env.DB_PORT || '27017'), database: process.env.DB_DATABASE || 'test', options: {} } }); class User extends Model { static get collection() { return 'users'; } static get connection() { return 'mongodb'; } } async function createUser() { const user = new User(); user.name = 'John'; user.email = 'john@example.com'; await user.save(); console.log('User created:', user.toJSON()); } createUser().catch(console.error);
Debug
Known issues
breakingv3 changes condition object pattern: use MongoDB operators ($or, $gte) instead of lucid-mongo v2 operators (or, gte).
fix
Replace operators: { or: ... } -> { $or: ... }, { gte: 18 } -> { $gte: 18 }
affects: >=3.0.0
deprecatedv1 uses generator functions (yield) which are deprecated. v2 and v3 use async/await.
fix
Upgrade to v2+ and rewrite yield to async/await.
affects: 1.x
gotchaThe package is not maintained by AdonisJS core team; community-driven with potential delays in updates.
fix
Monitor GitHub for issues; consider forking or using another ODM if immediate support needed.
affects: all
Errors
Common errors & fixes
Cannot find module 'lucid-mongo'
Package not installed or incorrectly referenced.
fix
Run npm install lucid-mongo --save
lucid-mongo/providers/LucidMongoProvider is not a constructor
Wrong import path or missing export.
fix
Use: import { LucidMongoProvider } from 'lucid-mongo/providers/LucidMongoProvider'
Upgrade
Version history
3.1.6latest on npm
Audit
Dependencies
@adonisjs/lucidoptionalInherits Lucid ORM patterns; may require peer dependency for certain features.
Agent activity
7 hits · last 30 days
node
6
Resources