{"id":25048,"library":"cache-database","title":"cache-database","description":"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.","status":"active","version":"1.3.3","language":"javascript","source_language":"en","source_url":"https://github.com/polozov-nikita/cache-database","tags":["javascript","cache","db"],"install":[{"cmd":"npm install cache-database","lang":"bash","label":"npm"},{"cmd":"yarn add cache-database","lang":"bash","label":"yarn"},{"cmd":"pnpm add cache-database","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package provides a CommonJS default export. ESM import may not work as there is no 'exports' field.","wrong":"import cache from 'cache-database';","symbol":"default","correct":"const cache = require('cache-database');"},{"note":"create() returns a collection object. The package does not export named functions.","wrong":"cache.Collection('collection')","symbol":"create","correct":"cache.create('collection');"},{"note":"Function signature: find(query, projection, skip, limit). The skip and limit are positional, not in an object.","wrong":"collection.find({a: 1}, {b: 0}, 30, 10)","symbol":"collection.find","correct":"collection.find({a: 1}, {b: 0}).then(data => {})"}],"quickstart":{"code":"const cache = require('cache-database');\nconst collection = cache.create('users');\n\ncollection.create({name: 'Alice', age: 30})\n  .then(() => collection.find({age: {$gte: 25}}))\n  .then(result => console.log(result.data))\n  .catch(err => console.error(err));","lang":"javascript","description":"Shows how to require the default export, create a collection, insert a document, and query with a MongoDB-style operator."},"warnings":[{"fix":"Access result.data for the documents array.","message":"find() returns an object with data, search, skip, sort, records — not just an array.","severity":"gotcha","affected_versions":">=0.0.0"},{"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.","message":"The sort parameter in find() is the third argument, not a separate options object.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use .then() or await inside async functions.","message":"All operations are async and return Promises; synchronous usage will cause issues.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use const cache = require('cache-database');","cause":"Importing the package incorrectly (using named import instead of default).","error":"TypeError: cache.create is not a function"},{"fix":"Ensure you await the promise: const result = await collection.find(...);","cause":"Forgetting to return or await the promise from find().","error":"TypeError: Cannot read property 'data' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}