Registry / database / feathers-mongodb-management

feathers-mongodb-management

JSON →
library2.0.1jsnpmunverified

FeathersJS service adapters for managing MongoDB databases, collections, and users. Version 2.0.1 supports Feathers v5 (Dove) and Node.js >=16, while v1.x supports Feathers v3 (Buzzard) and Node.js >=12. Differentiates from standard MongoDB adapters by enabling physical data segregation per tenant (e.g., organizations) via dedicated databases, simplifying access control in multi-tenant SaaS applications. The plugin provides CRUD services for creating, listing, and dropping databases/collections/users through standard Feathers service interfaces. Release cadence is low; relies on mongodb native driver.

npm install feathers-mongodb-management
INSTALL
IMPORT
SIG · FEATHERS-MONGODB-M
F
feathers-mongodb-management
databasejavascriptv2.0.1
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
import { database } from 'feathers-mongodb-management'
const database = require('feathers-mongodb-management').database
ESM and CJS both supported; named export for database service adapter.
collection
import { collection } from 'feathers-mongodb-management'
const collection = require('feathers-mongodb-management').collection
Named export; must be invoked with db instance.
user
import { user } from 'feathers-mongodb-management'
const user = require('feathers-mongodb-management').user
Named export; requires db and optional roles config.

Demonstrates setting up database, collection, and user management services with Feathers v5 and MongoDB.

const { app, mongodb } = require('@feathersjs/feathers'); const { database, collection, user } = require('feathers-mongodb-management'); const client = await mongodb.MongoClient.connect('mongodb://localhost:27017'); const adminDb = client.db('admin').admin(); // Register database management service app.use('/mongo/databases', database({ adminDb, client })); const dbService = app.service('/mongo/databases'); // Create a new database const dbMeta = await dbService.create({ name: 'my-tenant-db' }); const tenantDb = client.db('my-tenant-db'); // Register collection and user services for that database app.use('/mongo/my-tenant-db/collections', collection({ db: tenantDb })); app.use('/mongo/my-tenant-db/users', user({ db: tenantDb })); const collService = app.service('/mongo/my-tenant-db/collections'); const createdColl = await collService.create({ name: 'my-collection' }); console.log('Collection created:', createdColl);
Debug
Known issues
breakingv2.x requires Feathers v5 (Dove) and Node.js >=16; v1.x is deprecated and incompatible with Feathers v5.
fix
Update to Feathers v5 and Node.js 16+. For Feathers v3, stick to v1.x.
affects: >=2.0.0
deprecatedThe plugin has low release cadence; no updates since 2021. Not actively maintained apart from critical patches.
fix
Consider alternative data segregation strategies if needed.
affects: *
gotchaThe 'database' service returns metadata objects, not MongoDB Db instances. You need to call client.db(name) to get the actual DB.
fix
After creating a database via service, retrieve the Db instance with client.db(name).
affects: *
gotchaCollection and user services requires a MongoDB Db instance (from client.db()), not the adminDb or metadata.
fix
Pass client.db('your-db') when configuring collection/user service.
affects: *
gotchaThe 'user' service requires the target database to have a 'users' collection with proper indexes (e.g., unique on username). Otherwise operations may fail.
fix
Ensure the database has a 'users' collection with appropriate schema before using the user service.
affects: *
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'admin')
adminDb parameter is not a valid MongoDB Admin object; likely missing .admin() call.
fix
Ensure you pass adminDb: client.db('admin').admin() instead of client.db('admin').
Error: Service 'collection' expects a 'db' option
Missing db option when creating collection service.
fix
Pass { db: client.db('your-db') } as options to plugin.collection()
MongoError: database com not empty because of collection ...
Attempting to drop a non-empty database.
fix
Drop all collections inside the database first, or use the 'force' option if supported by the service.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
@feathersjs/feathersrequiredPeer dependency required for Feathers v5 compatibility
@feathersjs/errorsrequiredRequired for error handling in service methods
mongodbrequiredMongoDB native driver for database operations
Agent activity
2 hits · last 30 days
node
2
Resources
feathers-mongodb-management — npm install feathers-mongodb-management · libregistry