Registry / database / seneca-mongo-store

seneca-mongo-store

JSON →
library5.0.1jsnpmunverified

A Seneca.js data storage plugin for MongoDB, version 5.0.1. Provides persistence using MongoDB for Seneca entity API. Supports standard Seneca query operations including sorting, limiting, skipping, and field selection. Connection via URI or key-based options. Works with Seneca 3.x. Uses native MongoDB driver under the hood. Active development with regular releases.

npm install seneca-mongo-store
INSTALL
IMPORT
SIG · SENECA-MONGO-STORE
S
seneca-mongo-store
databasejavascriptv5.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.

seneca
import seneca from 'seneca'
const seneca = require('seneca')
ESM import for Seneca 3.x
mongo-store
seneca.use('mongo-store', options)
seneca.use(require('seneca-mongo-store'))
Plugin is loaded as a string, not by passing the module
entity
seneca.make$('typename')
seneca.make('typename')
Entity creation uses make$ not make

Shows how to connect to MongoDB, create an entity, save it, and list entities.

import seneca from 'seneca' const si = seneca() si.use('entity') si.use('mongo-store', { uri: process.env.MONGO_URI ?? 'mongodb://127.0.0.1:27017/test' }) si.ready(async () => { const apple = si.make$('fruit') apple.name = 'Pink Lady' apple.price = 0.99 await apple.save$() console.log('Saved apple with id:', apple.id) const list = await si.entity('fruit').list$({ name: 'Pink Lady' }) console.log('List:', list) })
Debug
Known issues
deprecatedSupport for Seneca versions < 3.x is removed
fix
Upgrade to Seneca 3.x
affects: >=5.0.0 <6.0.0
gotchaThe store requires the 'entity' plugin to be loaded before 'mongo-store'
fix
Call si.use('entity') before si.use('mongo-store', ...)
affects: >=1.0.0
breakingAPI changed from callback-based to promise-based in Seneca 3.x; older patterns may not work
fix
Use async/await or promises instead of callbacks for save$, load$, list$, remove$
affects: >=5.0.0 <6.0.0
gotchaEntity methods use $ suffix (save$, load$, etc.); omitting $ results in errors
fix
Always use the $ suffix: save$, load$, list$, remove$
affects: >=1.0.0
Errors
Common errors & fixes
Entity is not a constructor
Missing 'entity' plugin before 'mongo-store'
fix
Ensure si.use('entity') is called before si.use('mongo-store')
Cannot read properties of undefined (reading 'id')
Using load$ with invalid id or not waiting for promise
fix
Use await or callback properly: const result = await entity.load$({id: '...'})
MongoError: Authentication failed
Incorrect credentials or connection string format
fix
Check MONGO_URI environment variable or options passed to .use()
Upgrade
Version history
5.0.1latest on npm
Audit
Dependencies
senecaoptionalPeer dependency; plugin requires Seneca 3.x
Agent activity
8 hits · last 30 days
node
6
Meta
1
Resources
seneca-mongo-store — npm install seneca-mongo-store · libregistry