Registry / database / save
library2.9.0jsnpmunverified

A simple CRUD-based persistence abstraction for storing objects to any backend data store, v2.9.0 (current stable). Released periodically, with support for in-memory, MongoDB, and custom engines via a plugin architecture. Differentiators: unified API across multiple backends, built-in event hooks for CRUD operations, and a lightweight design that decouples application logic from specific databases.

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

save
const save = require('save')
import save from 'save'
CommonJS module; no default ESM export as of v2.9.0
save function
const s = save('person')
const s = new save('person')
save() is a factory function, not a constructor; no new keyword.
idProperty
const s = save('person', { idProperty: '_id' })
s.idProperty = '_id'
Set idProperty in options during initialization, not after.

Initializes a 'save' instance for 'person' model with in-memory engine, performs CRUD operations (create, read, update, delete).

const save = require('save'); const s = save('person'); s.create({ name: 'Dom' }, function(err, person) { if (err) throw err; console.log(person); }); s.read(1, function(err, person) { if (err) throw err; console.log(person); }); s.update({ _id: 1, name: 'Dominic' }, false, function(err, person) { if (err) throw err; console.log(person); }); s.delete(1, function(err) { if (err) throw err; console.log('Deleted'); });
Debug
Known issues
gotchasave() is a function, not a constructor. Do not use 'new'.
fix
Use const s = save('person') without new.
affects: >=2.0.0
deprecatedOptions like 'logger' are engine-specific; some engines may ignore them.
fix
Check engine documentation for supported options.
affects: >=2.5.0
gotchaThe in-memory engine is not persistent; data is lost on restart.
fix
Use a persistent engine like save-mongodb for production.
affects: >=2.0.0
gotchadeleteMany() performs find then delete for each item; not atomic.
fix
For atomic deletes, use engine-specific methods.
affects: >=2.0.0
breakingEvent names changed between versions; 'afterCreate' not 'create' for post-create.
fix
Use 'afterCreate', 'afterUpdate', etc. as per v2+.
affects: <2.0.0
Errors
Common errors & fixes
TypeError: save is not a function
Using require incorrectly or importing ESM style
fix
Use const save = require('save');.
Error: Cannot find module 'save'
Package not installed
fix
Run npm install save.
TypeError: s.create is not a function
save() called with 'new' or wrong instance
fix
Use const s = save('person') without new.
Upgrade
Version history
2.9.0latest on npm
Audit
Dependencies
save-mongodboptionalRecommended MongoDB engine for real-world use
Agent activity
11 hits · last 30 days
node
10
Meta
1
Resources
packagesave
save — npm install save · libregistry