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()
Errors
Common errors & fixes
Error: Cannot find module 'adonis-lucid-mongodb/providers/LucidMongoProvider'
Package not installed or path incorrect.
fixRun '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.
fixRun your code within AdonisJS application (e.g., via ace commands).
MongoError: cannot use 'collection' with 'where'
Using MongoDB terminology incorrectly or mixing query syntax.
fixUse 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.
fixUse npm dedupe or move project to shorter path.
Audit
Dependencies
@adonisjs/foldrequiredIoC container dependency used by Adonis framework
@adonisjs/lucidrequiredBase ORM that this package extends/modifies