Registry / database / integreat-adapter-mongodb

integreat-adapter-mongodb

JSON →
library0.3.2jsnpmunverified

An adapter that allows Integreat to use MongoDB as a data source. Version 0.3.2 is the latest stable release, targeting Node >=12.9 and Integreat v0.6. It provides a simple configuration-based mapping from Integreat actions to MongoDB operations (find, update, delete). Unlike generic MongoDB drivers, it integrates natively with Integreat's authentication, paging, and query param system. Adheres to Integreat's adapter interface and uses resources pattern.

npm install integreat-adapter-mongodb
INSTALL
IMPORT
SIG · INTEGREAT-ADAPTER-
I
integreat-adapter-mongodb
databasejavascriptv0.3.2
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.

default
import mongodb from 'integreat-adapter-mongodb'
const { mongodb } = require('integreat-adapter-mongodb')
Package exports a single function as default. CommonJS users should use `const mongodb = require('integreat-adapter-mongodb')`.
IntegreatAdapterMongo
import mongodb from 'integreat-adapter-mongodb'
import { IntegreatAdapterMongo } from 'integreat-adapter-mongodb'
The package has no named export. Use default import.
require
const mongodb = require('integreat-adapter-mongodb')
const mongodb = require('integreat-adapter-mongodb').default
CommonJS require returns the function directly, not an object with default property.

Initializes Integreat with the MongoDB adapter, configures a source with URI, then dispatches a GET action to retrieve documents.

import integreat from 'integreat'; import mongodbAdapter from 'integreat-adapter-mongodb'; const resources = mongodbAdapter(integreat.resources()); const defs = { sources: [ { id: 'store', adapter: 'mongodb', auth: true, options: { uri: process.env.MONGO_URI || 'mongodb://localhost:27017', }, endpoints: [ { options: { db: 'mydb', collection: 'items' }, }, ], }, ], }; const great = integreat(defs, resources); // Dispatch an action to get documents const action = { type: 'GET', payload: { source: 'store', params: { pageSize: 10 }, }, }; great.dispatch(action).then((response) => { console.log(response.data); });
Debug
Known issues
gotchaUsing dots in query paths requires escaping: use 'attributes\\.status' instead of 'attributes.status'.
fix
Escape dots with double backslash in the path property of query objects.
affects: >=0.0.0
gotchaUpdating and deleting arrays of documents uses individual updateOne/deleteOne calls per item, which is inefficient.
fix
Consider using bulkWrite operations for better performance.
affects: >=0.0.0 <0.4.0
gotchaIncluding credentials in the connection URI is common but requires auth: true on source to enable Integreat's security.
fix
Set auth: true in source definition when URI contains credentials.
affects: >=0.0.0
deprecatedIntegreat adapter pattern may change in future versions; check compat with Integreat updates.
fix
Review adapter interface when upgrading Integreat.
affects: >=0.3.0
Errors
Common errors & fixes
Cannot find module 'integreat-adapter-mongodb'
Package not installed or incorrect import path.
fix
Run `npm install integreat-adapter-mongodb` and ensure import path is correct.
TypeError: mongodb is not a function
Using named import instead of default import in CommonJS.
fix
Use `const mongodb = require('integreat-adapter-mongodb')` (no destructuring).
Error: adapter 'mongodb' not found
Resources not configured with the adapter function.
fix
Call `mongodbAdapter(integreat.resources())` before creating Integreat instance.
MongoError: Authentication failed
Credentials in URI incorrect or not accepted without auth: true.
fix
Verify URI credentials and set `auth: true` on source definition.
Upgrade
Version history
0.3.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
integreat-adapter-mongodb — npm install integreat-adapter-mongodb · libregistry