Registry / database / redisk

redisk

JSON →
library2.1.7jsnpmunverified

Redisk is a TypeScript ORM for Redis, currently at version 2.1.7. It provides decorator-based entity mapping with support for primary keys, unique keys, indexes, and relations (HasOne). It allows CRUD operations, filtering with multiple conditions, pattern matching (similar to LIKE), and list queries with pagination and sorting. Compared to other Redis ORMs, it offers a TypeScript-first approach with decorators, built-in cascade operations for relations, and a query API that resembles traditional SQL ORMs. It supports connections via URL or individual options and includes logging.

npm install redisk
INSTALL
IMPORT
SIG · REDISK
R
redisk
databasejavascriptv2.1.7
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.

Redisk
import { Redisk } from 'redisk'
import * as Redisk from 'redisk'
Redisk is a named export, not a default export.
Entity
import { Entity } from 'redisk'
const Entity = require('redisk').Entity
Named import from the package; CommonJS require is supported but ESM is recommended.
Primary
import { Primary } from 'redisk'
import Primary from 'redisk'
Primary is a named export, not a default export.
Property
import { Property } from 'redisk'
const Property = require('redisk').Property
Named export; can be imported with other decorators.
Unique
import { Unique } from 'redisk'
import { Unique } from 'redisk/decorators'
Unique is exported from the main package, not a submodule.
HasOne
import { HasOne } from 'redisk'
HasOne is a named export for defining one-to-one relations.

Demonstrates initializing Redisk with a Redis URL, defining a User entity with decorators, saving an instance, and retrieving it by primary key.

import { Redisk, Entity, Primary, Property, Unique } from 'redisk'; @Entity('user') class User { @Primary() @Property() public id: string; @Property() public name: string; @Unique() @Property() public email: string; constructor(id: string, name: string, email: string) { this.id = id; this.name = name; this.email = email; } } async function main() { const redisk = await Redisk.init({ url: process.env.REDIS_URL ?? 'redis://localhost:6379/0' }); const user = new User('1', 'Alice', 'alice@example.com'); await redisk.save(user); const retrieved = await redisk.getOne(User, '1'); console.log(retrieved); await redisk.close(); } main().catch(console.error);
Debug
Known issues
deprecatedThe 'canBeListed' option in @Entity decorator is deprecated and may be removed in future versions.
fix
Remove the option or use the default (true).
affects: >=2.0.0
gotchaDo not combine @Unique() with @Indexed() on the same property; unique keys automatically create an index.
fix
Remove @Indexed() if @Unique() is already present.
affects: >=1.0.0
breakingRedisk.init() is now async and returns a Promise. In older versions it was synchronous.
fix
Use await Redisk.init(options) or .then() to get the instance.
affects: >=2.0.0
deprecatedThe 'create' method is deprecated; use 'save' instead.
fix
Replace redisk.create(entity) with redisk.save(entity).
affects: >=2.1.0
gotchaProperties not decorated with @Property() are not persisted to Redis.
fix
Ensure all persisted fields are decorated with @Property().
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: redisk.save is not a function
Redisk.init() was not awaited, so 'redisk' is a Promise object instead of a Redisk instance.
fix
const redisk = await Redisk.init(options);
ERR wrong number of arguments for 'hset' command
A property value contains an object or array that is not serializable to a string.
fix
Ensure all @Property() fields are primitive types (string, number, boolean) or use @HasOne for relations.
Entity 'User' has no primary key defined
The entity class is missing @Primary() decorator on any property.
fix
Add @Primary() decorator to the property that serves as the primary key.
Cannot find name 'Redisk'. Did you mean 'Redis'?
The package 'redisk' is not installed or TypeScript cannot resolve it.
fix
Run 'npm install redisk' and ensure tsconfig.json includes 'node_modules/@types' or has 'esModuleInterop' enabled.
Upgrade
Version history
2.1.7latest on npm
Audit
Dependencies
redisrequiredRequired to connect to and interact with Redis server.
Agent activity
7 hits · last 30 days
node
6
Meta
1
Resources
packageredisk
redisk — npm install redisk · libregistry