Registry / database / adonis-lucid-mongodb

adonis-lucid-mongodb

JSON →
library1.1.0jsnpmunverified

A MongoDB query builder and ODM for AdonisJS 3.x, based on Adonis Lucid. Current stable version is 1.1.0, targeting Adonis 3.x. It provides MongoDB-specific features like aggregation, geospatial queries, and relations (hasOne, morphMany) while dropping join-based features. Note: v2.x was published under a new name 'lucid-mongo' for Adonis 4.x. This package is no longer actively maintained; users should migrate to 'lucid-mongo' for newer Adonis versions.

npm install adonis-lucid-mongodb
INSTALL
IMPORT
SIG · ADONIS-LUCID-MONGO
A
adonis-lucid-mongodb
databasejavascriptv1.1.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.

LucidMongo
const LucidMongo = require('adonis-lucid-mongodb')
import LucidMongo from 'adonis-lucid-mongodb'
Uses CommonJS require; no ESM support.
Model
const Model = use('Model')
const { Model } = require('adonis-lucid-mongodb')
Model is auto-loaded via Adonis IoC container with use('Model'). Not directly imported from package.
Database
const Database = use('Database')
const Database = require('adonis-lucid-mongodb')
Database provider is registered via Adonis providers list, accessed with use('Database').

Shows full setup: install, register provider, configure MongoDB connection, define a model, and query all users.

// 1. Install // npm i adonis-lucid-mongodb // 2. Register provider in start/app.js const providers = [ 'adonis-lucid-mongodb/providers/LucidMongoProvider' ] // 3. Configure database: config/database.js module.exports = { mongodb: { client: 'mongo', connection: { host: process.env.DB_HOST || '127.0.0.1', port: 27017, database: 'myapp', user: process.env.DB_USER || '', password: process.env.DB_PASS || '' } } } // 4. Define a model: app/Models/User.js 'use strict' const Model = use('Model') class User extends Model { static get collection () { return 'users' } } module.exports = User // 5. Use the model const User = use('App/Models/User') const users = await User.all()
Debug
Known issues
breakingVersion 2.x renamed to lucid-mongo; adonis-lucid-mongodb is for Adonis 3.x only.
fix
Use 'lucid-mongo' package for Adonis 4.x.
affects: >=2.0.0
deprecatedThis package is no longer maintained; no updates or security patches.
fix
Migrate to lucid-mongo or another MongoDB ODM (e.g., Mongoose).
affects: >=0.0.0
gotchaMust replace all adonis-lucid settings with adonis-lucid-mongodb in config/database.js; mixing both configs will break.
fix
Use only mongodb config, remove sql config.
affects: >=0.0.0
gotchaNo join-related queries like has, whereHas, doesntHave, whereDoesntHave are supported.
fix
Use aggregation or client-side joining instead.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'adonis-lucid-mongodb/providers/LucidMongoProvider'
Package not installed or path incorrect.
fix
Run 'npm install adonis-lucid-mongodb' and ensure provider path is exact.
ReferenceError: use is not defined
use() is only available inside AdonisJS context, not in raw Node.js.
fix
Run your code within AdonisJS application (e.g., via ace commands).
MongoError: cannot use 'collection' with 'where'
Using MongoDB terminology incorrectly or mixing query syntax.
fix
Use LucidMongo query syntax as documented; avoid raw mongo operators directly.
Error: ENAMETOOLONG: name too long, open '.../node_modules/adonis-lucid-mongodb/...'
Windows path length limit when using npm with deeply nested node_modules.
fix
Use npm dedupe or move project to shorter path.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
@adonisjs/foldrequiredIoC container dependency used by Adonis framework
@adonisjs/lucidrequiredBase ORM that this package extends/modifies
Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
1
Resources
adonis-lucid-mongodb — npm install adonis-lucid-mongodb · libregistry