Registry / database / redis-om-typed

redis-om-typed

JSON →
library0.4.3-5jsnpmunverified

Object mapping and search for Redis and Node.js, written in TypeScript. Current stable version is 0.4.3-5, released as a pre-release with breaking changes from 0.3.x. Provides a fluent repository pattern to define schemas, save entities as JSON or Hashes, and search using typed queries. Supports full-text search, pagination, sorting, and geospatial queries. Built on top of node-redis (v4) and requires Redis Stack for indexing and search capabilities. Differentiators: type-safe schema definitions, chained query builder, and transparent mapping between Redis data structures and JavaScript objects.

npm install redis-om-typed
INSTALL
IMPORT
SIG · REDIS-OM-TYPED
R
redis-om-typed
databasejavascriptv0.4.3-5
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.

Schema
import { Schema } from 'redis-om-typed'
const Schema = require('redis-om-typed').Schema
Both ESM and CJS are supported in v0.4.3-5, but TypeScript types are only available with ESM imports.
Repository
import { Repository } from 'redis-om-typed'
import { Repository } from 'redis-om-types'
Repository is not exported as a class to instantiate directly; use client.fetchRepository(schema).
Client
import { Client } from 'redis-om-typed'
import { createClient } from 'redis'
Client wraps node-redis client with OM-specific methods like fetchRepository.

Connects to Redis, defines a schema, creates an entity, builds a search index, inserts a record, and performs a chained search query.

import { Client, Schema, EntityId } from 'redis-om-typed'; import { createClient } from 'redis'; const redisClient = createClient({ url: process.env.REDIS_URL ?? 'redis://localhost:6379' }); await redisClient.connect(); const client = await new Client().use(redisClient); const albumSchema = new Schema('album', { artist: { type: 'string' }, title: { type: 'text' }, year: { type: 'number' }, }); const repository = client.fetchRepository(albumSchema); await repository.createIndex(); const album = repository.createEntity(); album.artist = 'Mushroomhead'; album.title = 'The Righteous & The Butterfly'; album.year = 2014; await repository.save(album); const albums = await repository.search() .where('artist').equals('Mushroomhead') .and('title').matches('butterfly') .and('year').is.greaterThan(2000) .return.all(); console.log(albums); await redisClient.disconnect();
Debug
Known issues
breakingv0.4.0 introduced breaking changes from v0.3.x, including different API for Client and Repository instantiation.
fix
Use Client.use() to attach node-redis client, and fetchRepository(schema) instead of new Repository(schema, client).
affects: >=0.4.0
deprecatedThe use of Schema as a constructor with Redis OM v0.3 style is deprecated. Schema must be imported from 'redis-om-typed'.
fix
Update import to from 'redis-om-typed' and use new Schema(name, fields).
affects: <0.4.0
gotchaEntity properties must be set as plain properties, not using methods. There is no 'set' method; assign directly.
fix
Use entity.property = value instead of entity.set('property', value).
affects: *
gotchaSearch queries are case-sensitive by default for string/word searches. Use 'matches' (full-text) for case-insensitive.
fix
For case-insensitive search on text fields, use .matches() instead of .equals().
affects: *
gotchaRepository methods return promises, including save() and fetch(). Must await or handle asynchronously.
fix
Always await repository.save(entity) and repository.fetch(id).
affects: *
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'save')
Trying to use repository methods on an entity that hasn't been created via repository.createEntity().
fix
Create the entity with repository.createEntity() before setting properties and calling save().
ReplyError: ERR unknown command 'FT.CREATE'
Redis server does not have the RediSearch module (Redis Stack) enabled.
fix
Install Redis Stack or enable the RediSearch module via redis-stack-server or docker: docker run -p 6379:6379 redis/redis-stack-server:latest.
TypeError: client.fetchRepository is not a function
The Client instance does not have fetchRepository method; possible incorrect import or older version.
fix
Ensure you are using v0.4.0+ and importing Client from 'redis-om-typed'. Use client.use(redisClient) first.
UnhandledPromiseRejectionWarning: Error: Redis connection to localhost:6379 failed - connect ECONNREFUSED
Redis server is not running or not accessible at the given URL.
fix
Start Redis server locally or set REDIS_URL environment variable to a valid Redis connection string.
Upgrade
Version history
0.4.3-5latest on npm
Audit
Dependencies
redisrequiredRequired for Redis connection and commands
Agent activity
15 hits · last 30 days
node
12
Meta
1
Resources
redis-om-typed — npm install redis-om-typed · libregistry