Registry / database / cache-database

cache-database

JSON →
library1.3.3jsnpmunverified

A lightweight, promise-based in-memory database with MongoDB-like query syntax (e.g., $in, $gte, $lte) for Node.js. Version 1.3.3 (last release appears infrequent, no clear cadence) provides basic CRUD operations, sorting, skipping, and field projection. Unlike full databases, it stores data in memory without persistence, making it suitable for caching or prototyping. No external dependencies.

npm install cache-database
INSTALL
IMPORT
SIG · CACHE-DATABASE
C
cache-database
databasejavascriptv1.3.3
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
const cache = require('cache-database');
import cache from 'cache-database';
The package provides a CommonJS default export. ESM import may not work as there is no 'exports' field.
create
cache.create('collection');
cache.Collection('collection')
create() returns a collection object. The package does not export named functions.
collection.find
collection.find({a: 1}, {b: 0}).then(data => {})
collection.find({a: 1}, {b: 0}, 30, 10)
Function signature: find(query, projection, skip, limit). The skip and limit are positional, not in an object.

Shows how to require the default export, create a collection, insert a document, and query with a MongoDB-style operator.

const cache = require('cache-database'); const collection = cache.create('users'); collection.create({name: 'Alice', age: 30}) .then(() => collection.find({age: {$gte: 25}})) .then(result => console.log(result.data)) .catch(err => console.error(err));
Debug
Known issues
gotchafind() returns an object with data, search, skip, sort, records — not just an array.
fix
Access result.data for the documents array.
affects: >=0.0.0
gotchaThe sort parameter in find() is the third argument, not a separate options object.
fix
Pass sort as the third argument, e.g., find(query, projection, sort, skip, limit) – but the README shows sort as third or fourth; check documentation.
affects: >=0.0.0
gotchaAll operations are async and return Promises; synchronous usage will cause issues.
fix
Use .then() or await inside async functions.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: cache.create is not a function
Importing the package incorrectly (using named import instead of default).
fix
Use const cache = require('cache-database');
TypeError: Cannot read property 'data' of undefined
Forgetting to return or await the promise from find().
fix
Ensure you await the promise: const result = await collection.find(...);
Upgrade
Version history
1.3.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
cache-database — npm install cache-database · libregistry