Rocket-Store

0.10.20 · active · verified Wed Apr 22

Rocket-Store is a lightweight, high-performance flat-file database solution for Node.js, currently at version `0.10.20`. It distinguishes itself by directly leveraging the host operating system's file system caching mechanisms for exceptionally fast data storage and retrieval. Designed for scenarios requiring minimal footprint and high throughput, it stores data in JSON format within collections and records, accessible via unique keys. The package requires no complex configuration or setup, defaulting to the OS temporary directory for data storage, and supports both CommonJS and ES Modules. While specific release cadence isn't explicitly defined, frequent updates indicate active maintenance. Its key differentiators include simplicity, asynchronous mutation safety, and a single-file core with few external dependencies, making it an efficient alternative to more complex database systems for specific use cases.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic setup, configuring the storage area, and performing CRUD operations (post, get, delete) with specific keys and wildcard searches.

import * as rsModule from 'rocket-store';
import type { RocketStoreInstance } from 'rocket-store';
import { join } from 'path';
import { tmpdir } from 'os';

const main = async () => {
  const rs: RocketStoreInstance = await rsModule.Rocketstore();

  // Set a custom storage directory (optional, defaults to OS temp dir)
  await rs.setOption({ data_storage_area: join(tmpdir(), 'my-rocket-data') });

  // 1. Post a record
  const postResult = await rs.post("cars", "Mercedes-C200", { owner: "Lisa Simpson", reg: "N3RD" });
  console.log('Posted Mercedes:', postResult);

  // 2. Post another record with an auto-incremented key
  const postResult2 = await rs.post("cars", null, { owner: "Homer Simpson", reg: "DUFF" }, rs._ADD_AUTO_INC);
  console.log('Posted Homer (auto-inc key):', postResult2);

  // 3. Get all records from the 'cars' collection, ordered descending
  const allCars = await rs.get("cars", "*", rs._ORDER_DESC);
  console.log('All cars (descending):', allCars);

  // 4. Get a specific record by key
  const mercedes = await rs.get("cars", "Mercedes-C200");
  console.log('Mercedes record:', mercedes);

  // 5. Delete records matching a wildcard pattern (e.g., all with 'Cede' in key)
  const deleteResult = await rs.delete("cars", "*cede*");
  console.log('Deleted records matching *cede*:', deleteResult);

  // 6. Get remaining records
  const remainingCars = await rs.get("cars", "*");
  console.log('Remaining cars:', remainingCars);
};

main().catch(console.error);

view raw JSON →