Registry / database / sharedb-mingo-memory

sharedb-mingo-memory

JSON →
library4.1.0jsnpmunverified

sharedb-mingo-memory is an in-memory database adapter for ShareDB, providing a local, fast, and ephemeral data store that supports a subset of MongoDB's query API through the Mingo library. Its primary use cases include accelerating application testing by eliminating external database dependencies and facilitating local development environments. The current stable version is 4.1.0, with a release cadence tied to Node.js LTS versions and new major releases of ShareDB itself, ensuring broad compatibility. Key differentiators include its lightweight, in-memory nature, making it ideal for CI/CD pipelines and quick prototyping, while still offering a familiar MongoDB-like query interface. It integrates seamlessly with ShareDB applications for a mock database experience.

npm install sharedb-mingo-memory
INSTALL
IMPORT
SIG · SHAREDB-MINGO-MEMO
S
sharedb-mingo-memory
databasejavascriptv4.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ShareDBMingo
import ShareDBMingo from 'sharedb-mingo-memory';
const ShareDBMingo = require('sharedb-mingo-memory').default;
While CommonJS `require` is shown in older documentation, ESM `import` is the preferred and modern way. The module typically exports as a default.
ShareDBMingo
const ShareDBMingo = require('sharedb-mingo-memory');
This is the classic CommonJS `require` syntax as demonstrated in the package's README, suitable for Node.js environments.
extendMemoryDB
import ShareDBMingo from 'sharedb-mingo-memory'; const CustomDB = ShareDBMingo.extendMemoryDB(SomeOtherMemoryDB);
const { extendMemoryDB } = require('sharedb-mingo-memory');
The `extendMemoryDB` method is a static property of the default export, not a named export itself. It's used for creating a new ShareDBMingo class that extends a specific `MemoryDB`.

This quickstart demonstrates how to initialize sharedb-mingo-memory, integrate it with ShareDB, create a document, and perform a basic query against the in-memory database.

import ShareDBMingo from 'sharedb-mingo-memory'; import ShareDB from 'sharedb'; // Initialize the in-memory database adapter const db = new ShareDBMingo(); // Initialize ShareDB with the in-memory adapter const backend = new ShareDB({ db }); // Example usage: Create a connection and a document const connection = backend.connect(); const doc = connection.get('myCollection', 'myDocument'); doc.fetch((err) => { if (err) throw err; if (doc.type === null) { // Create the document if it doesn't exist doc.create({ title: 'Hello World', content: 'This is an in-memory document.' }, (err) => { if (err) throw err; console.log('Document created:', doc.data); queryDocuments(); }); } else { console.log('Document already exists:', doc.data); queryDocuments(); } }); function queryDocuments() { const query = connection.query('myCollection', { title: 'Hello World' }); query.subscribe((err) => { if (err) throw err; console.log('Query results:', query.results.map(d => d.data)); // Remember to unsubscribe or close connection in a real app query.destroy(); connection.close(); }); }
Debug
Known issues
breakingNode.js v16 is no longer supported. Applications running on Node.js v16 or older will need to upgrade their Node.js environment to at least v18 to use sharedb-mingo-memory v4.0.0 and above.
fix
Upgrade your Node.js runtime to version 18 or newer. For projects that cannot upgrade, sharedb-mingo-memory v3.x.x should be used.
affects: >=4.0.0
breakingNode.js v14 is no longer supported. Applications running on Node.js v14 will need to upgrade their Node.js environment to at least v16 to use sharedb-mingo-memory v3.0.0 and above.
fix
Upgrade your Node.js runtime to version 16 or newer. For projects that cannot upgrade, sharedb-mingo-memory v2.x.x should be used.
affects: >=3.0.0 <4.0.0
breakingNode.js v12 is no longer supported. Applications running on Node.js v12 will need to upgrade their Node.js environment to at least v14 to use sharedb-mingo-memory v2.0.0 and above.
fix
Upgrade your Node.js runtime to version 14 or newer. For projects that cannot upgrade, sharedb-mingo-memory v1.x.x should be used.
affects: >=2.0.0 <3.0.0
gotchaThe `$aggregate` operator was not supported in earlier versions (pre-2.1.0) and would throw an error. Support for basic `$aggregate` was added in v2.1.0, and `$lookup` for `$aggregate` was added in v4.1.0.
fix
Upgrade to sharedb-mingo-memory v2.1.0 or higher for basic `$aggregate` support. For `$lookup` within `$aggregate`, upgrade to v4.1.0 or higher. Consult the mingo documentation for supported aggregation pipeline stages.
affects: <2.1.0
gotchaThe `process` global was previously a requirement, which could cause issues in certain non-Node.js environments. This requirement was dropped in v3.0.1.
fix
Upgrade to sharedb-mingo-memory v3.0.1 or higher to remove the dependency on the `process` global, improving compatibility with bundlers and alternative JavaScript runtimes.
affects: <3.0.1
Errors
Common errors & fixes
Error: $mapReduce is not supported
The `sharedb-mingo-memory` adapter does not implement the `$mapReduce` MongoDB operator.
fix
Refactor your query to avoid `$mapReduce` or consider using a different ShareDB database adapter that supports it (e.g., `sharedb-mongo`).
TypeError: ShareDBMingo is not a constructor
This error often occurs when attempting to `new` an imported module incorrectly, especially if mixing ESM `import` with CommonJS `require()` patterns or when the module exports a default that isn't directly constructible.
fix
Ensure you are using the correct import syntax for your module system. For ESM, use `import ShareDBMingo from 'sharedb-mingo-memory';`. For CommonJS, use `const ShareDBMingo = require('sharedb-mingo-memory');`.
RangeError: Invalid version: X.Y.Z (sharedb-mingo-memory)
This usually indicates an incompatibility between the version of `sharedb-mingo-memory` and the version of `sharedb` being used in your project, or a Node.js version mismatch.
fix
Check the `peerDependencies` of `sharedb-mingo-memory` to ensure your `sharedb` version is compatible. Also, verify that your Node.js runtime meets the minimum version required by `sharedb-mingo-memory` (e.g., v4.x requires Node.js >=18).
Upgrade
Version history
4.1.0latest on npm
Audit
Dependencies
sharedbrequiredThis package is an adapter for ShareDB and requires it as a peer dependency to function.
Agent activity
21 hits · last 30 days
node
18
Meta
2
OpenAI (training)
1
Resources