Typed, indexed records in Redis.
📖 Documentation: ilkkao.github.io/rigidDB
A promise-based Node.js library that stores plain JavaScript objects in Redis and makes them searchable through secondary indexes. Each operation runs as a single Lua script, so a record and its indexes are always updated together. Every write is validated against a predefined schema.
Requires Node.js 22 or later and Redis 6.2 or later. The package is an ES module and includes TypeScript type definitions.
npm install --save rigiddb
import RigidDB from 'rigiddb';
const store = new RigidDB('mydb', 42);
await store.setSchema({
cars: {
fields: {
model: { type: 'string', allowNull: false },
color: 'string',
mileage: 'int'
},
indexes: {
byModel: { unique: true, fields: [ { name: 'model', caseInsensitive: true } ] },
byColor: { unique: false, fields: [ 'color' ] }
}
}
});
const id = await store.create('cars', { model: 'sedan', color: 'blue', mileage: 12345 });
await store.find('cars', { color: 'blue' }); // [ 1 ]
await store.get('cars', id); // { model: 'sedan', color: 'blue', mileage: 12345 }See the documentation for range indexes, paging, transactions, schema migrations, and the full API.
The documentation site is built with VitePress from the docs directory and deployed to GitHub Pages on every push to master.
npm run docs:devMIT