Registry / database / save-mongodb

save-mongodb

JSON →
library2.1.0jsnpmunverified

MongoDB persistence engine for the save library. Version 2.1.0 provides a MongoDB-backed implementation of the save ODM/ORM interface, enabling MongoDB as a storage backend for models. Released under the New BSD License, it is designed for use with Node.js (>=6). Key differentiators: simple integration with save, streaming find(), and callback-based API. Suitable for projects already using save that need MongoDB support.

npm install save-mongodb
INSTALL
IMPORT
SIG · SAVE-MONGODB
S
save-mongodb
databasejavascriptv2.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.

saveMongodb
const saveMongodb = require('save-mongodb')
import saveMongodb from 'save-mongodb'
Package uses CommonJS; no default ES module export. Use require().

Shows how to set up a MongoDB connection, create a save store backed by MongoDB, and create a document.

const Db = require('mongodb').Db; const Server = require('mongodb').Server; const save = require('save'); const saveMongodb = require('save-mongodb'); const db = new Db('SimpleExample', new Server('localhost', 27017, {})); db.open(function (error, connection) { connection.collection('contact', function (error, collection) { const contactStore = save('Contact', { engine: saveMongodb(collection) }); contactStore.create({ name: 'Paul', email: 'paul@serby.net' }, function (error, contact) { console.log(contact); connection.close(); }); }); });
Debug
Known issues
gotchaRequires both 'mongodb' and 'save' as peer dependencies; must be installed separately.
fix
Run: npm install mongodb save
affects: >=0.0.0
gotchaUses callback-based API; no promise support in this version.
fix
Use callbacks or promisify with util.promisify().
affects: 2.1.0
Errors
Common errors & fixes
Error: Cannot find module 'mongodb'
Missing peer dependency mongodb.
fix
npm install mongodb
Error: Cannot find module 'save'
Missing peer dependency save.
fix
npm install save
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
mongodbrequiredPeer dependency for MongoDB driver
saverequiredRequired for the save ODM interface
Agent activity
10 hits · last 30 days
node
8
Meta
2
Resources
save-mongodb — npm install save-mongodb · libregistry