Registry / database / relational-redis-store

relational-redis-store

JSON →
library0.6.14jsnpmunverified

A fully typed Node.js library (v0.6.14, stable API) that adds a relational layer on top of Redis, supporting foreign keys, indexes, and queries that combine multiple records. It provides TypeScript generics for collection schemas and uses handy-redis as the Redis client. Compared to raw Redis or ioredis, it offers higher-level CRUD operations and type safety but lacks atomicity and transactions (planned). The library is lightweight, with no additional server-side requirements beyond Redis itself.

npm install relational-redis-store
INSTALL
IMPORT
SIG · RELATIONAL-REDIS-S
R
relational-redis-store
databasejavascriptv0.6.14
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.

Store
import Store from 'relational-redis-store'
const Store = require('relational-redis-store')
Default export only; both ESM and CJS are supported but default import is preferred.
default (Store)
import Store from 'relational-redis-store'
import { Store } from 'relational-redis-store'
Store is a default export; named import is incorrect.
type CollectionMap
type CollectionMap = { users: User; games: Game; }
Users define their own schema types; the library does not export a CollectionMap type.

Sets up a relational Redis store with typed collections, inserts a user and a game with foreign keys, and retrieves the game.

import * as redisSDK from 'handy-redis'; import Store from 'relational-redis-store'; type User = { id: string; name: string }; type Game = { id: string; players: [User['id'], User['id']]; winner?: User['id'] }; type CollectionMap = { users: User; games: Game }; const client = redisSDK.createHandyClient({ url: process.env.REDIS_URL ?? '' }); const store = new Store<CollectionMap>(client); // Create a user (must exist before creating a game referencing it) store.addItemToCollection('users', { name: 'Alice' }, 'alice-id', { foreignKeys: {} }); // Create a game referencing those users store.addItemToCollection('games', { players: ['alice-id', 'bob-id'] }, 'game-1', { foreignKeys: {} }); // Retrieve game with players (automatic relational resolution) store.getItemInCollection('games', 'game-1').then(game => console.log(game));
Debug
Known issues
gotchaForeign keys must reference existing items; no cascade delete or referential integrity enforcement.
fix
Ensure referenced items exist before inserting and manually handle deletions.
affects: >=0.0.0
breakingAPI assumes use of handy-redis; swapping to ioredis or node-redis requires adapter or wrapping.
fix
Use handy-redis or create a compatible client.
affects: >=0.0.0
deprecatedhandy-redis is deprecated (unmaintained); future versions may drop support.
fix
Consider wrapping ioredis to mimic handy-redis interface or wait for library update.
affects: >=0.0.0
gotchaNo built-in transaction support; operations are not atomic.
fix
Use MULTI/EXEC manually via the client if atomicity needed.
affects: >=0.0.0
gotchaTypeScript generics require explicit CollectionMap type; incorrect type definitions may cause runtime errors.
fix
Define and pass a correct CollectionMap type matching your data.
affects: >=0.0.0
breakingVersion 0.x: API may change without major version bump.
fix
Pin to exact version and review changelog before upgrading.
affects: >=0.0.0 <1.0.0
Errors
Common errors & fixes
Error: Redis connection failed: Connection refused
Redis server not running or incorrect REDIS_URL.
fix
Start Redis (e.g., `redis-server`) and ensure REDIS_URL is correct (e.g., redis://localhost:6379).
TypeError: store.addItemToCollection is not a function
Using named import instead of default import.
fix
Replace `import { Store } from 'relational-redis-store'` with `import Store from 'relational-redis-store'`.
Error: Foreign key 'players' references missing item 'nonexistent-id'
Referenced item does not exist in the target collection.
fix
Insert the referenced item before adding the item with foreign keys.
Error: Collection 'users' not found (creating item) - store.addItemToCollection throws if type mismatch?
Collection name does not match keys in CollectionMap type.
fix
Ensure collection name matches a key in your CollectionMap type (e.g., 'users').
Upgrade
Version history
0.6.14latest on npm
Audit
Dependencies
handy-redisrequiredprovides Redis client connections; the package wraps handy-redis and expects a client instance
Agent activity
3 hits · last 30 days
node
2
Meta
1
Resources