Registry / database / ts-redis-orm

ts-redis-orm

JSON →
library1.1.1jsnpmunverified

A TypeScript ORM for Redis that provides relational database features like multiple indexes, primary keys, unique keys, auto-increment, and aggregate functions (count, sum, min, max, average). Version 1.1.1 supports Redis 3, 4, and 5 via ioredis, but does not work with Redis Cluster. Breaking changes in v1 include all operations returning performance metrics and removal of soft delete and updatedAt/deletedAt columns. Designed for performance, creating ~10,000 entities per second per CPU process.

npm install ts-redis-orm
INSTALL
IMPORT
SIG · TS-REDIS-ORM
T
ts-redis-orm
databasejavascriptv1.1.1
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.

BaseEntity
✓ import { BaseEntity } from 'ts-redis-orm'
✗ import BaseEntity from 'ts-redis-orm'
Use named import; default export is not available.
Entity
✓ import { Entity } from 'ts-redis-orm'
✗ const Entity = require('ts-redis-orm').Entity
Works with CommonJS via destructuring, but ESM is preferred.
Column
✓ import { Column } from 'ts-redis-orm'
Decorator for defining columns.
redisOrm
✓ import { redisOrm } from 'ts-redis-orm'
✗ import { RedisOrm } from 'ts-redis-orm'
Function export, not a class; note lowercase 'o'.

Defines a simple entity with auto-increment id, unique name, and indexed age, then saves and retrieves it.

import { BaseEntity, Column, Entity } from 'ts-redis-orm'; @Entity({ connection: 'default', table: 'MyEntity' }) class MyEntity extends BaseEntity { @Column({ autoIncrement: true }) public id: number = 0; @Column({ unique: true }) public name: string = ''; @Column({ index: true }) public age: number = 0; } async function main() { await MyEntity.connect(); const entity = new MyEntity(); entity.name = 'Alice'; entity.age = 30; const [saved, perf] = await entity.save(); console.log('Saved entity:', saved); console.log('Performance:', perf); const [found] = await MyEntity.find({ where: { name: 'Alice' } }); console.log('Found:', found); } main().catch(console.error);
Debug
Known issues
breakingAll operations now return a performance result tuple [entity, performanceResult] instead of just entity. This changes function signatures for create().save(), find(), update() etc.
fix
Destructure the result: const [entity, perf] = await Entity.create({}).save();
affects: >=1.0.0
deprecatedupdatedAt and deletedAt columns have been removed. softDelete() and restore() methods are no longer available.
fix
Remove any usage of updatedAt, deletedAt columns and softDelete/restore methods from your code.
affects: >=1.0.0
gotchaThis package does NOT work with Redis Cluster due to design limitations. It only works with standalone Redis instances.
fix
Use a standalone Redis server or consider alternative ORMs like ioredis-based solutions that support cluster.
affects: >=0.0.0
gotchaSchema errors can occur if entity definitions change after data exists. You need to call resync() to align schema.
fix
Catch RedisOrmSchemaError and call entity.constructor.resync() or use the provided resync method.
affects: >=0.0.0
gotchaThe library uses decorators which require TypeScript's experimentalDecorators and emitDecoratorMetadata to be enabled.
fix
Add "experimentalDecorators": true and "emitDecoratorMetadata": true to your tsconfig.json.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot read properties of undefined (reading 'save')
Entity class not properly decorated with @Entity or not extending BaseEntity.
fix
Ensure your class has @Entity decorator and extends BaseEntity.
RedisOrmSchemaError: Schema mismatch for table <table>
Entity definition changed (e.g., new column added) while data exists in Redis.
fix
Call await Entity.resync() to synchronize the schema with the data.
TypeError: Class constructor MyEntity cannot be invoked without 'new'
Using the class as a regular function instead of instantiating with new.
fix
Use 'new MyEntity()' to create an instance.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
ioredisrequiredUnderlying Redis client used for all Redis operations
Agent activity
19 hits · last 30 days
node
16
Amazon
1
OpenAI (training)
1
Resources
ts-redis-orm — npm install ts-redis-orm · libregistry