cache-database

raw JSON →
1.3.3 verified Fri May 01 auth: no javascript

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.

error TypeError: cache.create is not a function
cause Importing the package incorrectly (using named import instead of default).
fix
Use const cache = require('cache-database');
error TypeError: Cannot read property 'data' of undefined
cause Forgetting to return or await the promise from find().
fix
Ensure you await the promise: const result = await collection.find(...);
gotcha find() returns an object with data, search, skip, sort, records — not just an array.
fix Access result.data for the documents array.
gotcha The 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.
gotcha All operations are async and return Promises; synchronous usage will cause issues.
fix Use .then() or await inside async functions.
npm install cache-database
yarn add cache-database
pnpm add cache-database

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));