npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

redis-orm-lite

v1.0.10

Published

A lightweight Redis ORM with a Mongoose-like API (find, findOne, updateMany, skip, limit, sort, etc.)

Readme

Redis ORM Lite

A lightweight Redis ORM for Node.js with a Mongoose-like API.

  • .create() — create a document
  • .find() / .findOne() / .findById() — query documents
  • .updateOne() / .updateMany() — update documents
  • .deleteOne() / .deleteMany() — delete documents
  • .findOneAndUpdate() / .findOneAndDelete() — find-then-modify
  • .countDocuments() — count matching documents
  • Query chaining: .sort(), .skip(), .limit(), .exec()

Requirements

  • Node.js ≥ 16
  • A running Redis server (local, Docker, or cloud)
  • TypeScript ≥ 5 (recommended, but not required for consumers)

Installation

npm install redis-orm-lite

Usage

import { RedisModel, connectRedis, RedisError } from "redis-orm-lite";

interface User {
  id?: string;
  name: string;
  email: string;
  age: number;
}

// Connect to Redis
await connectRedis("redis://localhost:6379");

// Create model
const UserModel = new RedisModel<User>("User");

// Create documents
const alice = await UserModel.create({
  name: "Alice",
  email: "[email protected]",
  age: 25,
});
await UserModel.create({ name: "Bob", email: "[email protected]", age: 30 });
await UserModel.create({ name: "Charlie", email: "[email protected]", age: 40 });

// Find with query + chaining
const adults = await UserModel.find({ age: { $gte: 18 } })
  .sort({ age: -1 })
  .skip(0)
  .limit(10)
  .exec();

// find() is thenable — works with await directly too:
const allUsers = await UserModel.find({});

// Find one
const firstAdult = await UserModel.findOne({ age: { $gte: 18 } });

// Find by ID
if (alice.id) {
  const userById = await UserModel.findById(alice.id);
}

// Count documents
const count = await UserModel.countDocuments({ age: { $gte: 18 } });

// Update one
const updated = await UserModel.updateOne({ id: alice.id }, { age: 26 });

// Update many
await UserModel.updateMany({ age: { $lt: 25 } }, { age: 25 });

// Delete
await UserModel.deleteOne({ id: alice.id });
await UserModel.deleteMany({ age: { $gte: 100 } });

// Find one and update (returns updated doc if returnNew: true)
await UserModel.findOneAndUpdate(
  { email: "[email protected]" },
  { age: 35 },
  { returnNew: true }
);

// Find one and delete
await UserModel.findOneAndDelete({ age: { $gte: 35 } });

Query Operators

| Operator | Meaning | |----------|---------| | $gt | greater than | | $gte | greater than or equal | | $lt | less than | | $lte | less than or equal | | $in | value in array | | $nin | value not in array | | $ne | not equal |


Chaining API

find() returns a QueryBuilder that supports:

const results = await UserModel.find({ age: { $gte: 21 } })
  .sort({ age: -1, name: 1 })   // sort by age desc, then name asc
  .skip(5)                       // skip first 5 results
  .limit(20)                     // limit to 20 results
  .exec();                       // execute the query

QueryBuilder is also thenable, so you can await it directly:

const results = await UserModel.find({ age: { $gte: 21 } });

Error Handling

All Redis operations throw RedisError on failure:

import { RedisModel, connectRedis, RedisError } from "redis-orm-lite";

try {
  const user = await UserModel.create({ name: "Alice", age: 25 });
} catch (err) {
  if (err instanceof RedisError) {
    console.error("Redis operation failed:", err.message, err.cause);
  }
}

API Reference

RedisModel<T>

| Method | Returns | Description | |--------|---------|-------------| | create(doc) | Promise<T> | Create a document (auto-generates id if missing) | | find(query) | QueryBuilder<T> | Build a query with chaining | | findOne(query) | Promise<T \| null> | Return first match or null | | findById(id) | Promise<T \| null> | Fetch by primary key | | updateMany(query, update) | Promise<number> | Update matching documents, returns count | | updateOne(query, update) | Promise<T \| null> | Update first match, returns updated doc | | findOneAndUpdate(query, update, opts?) | Promise<T \| null> | Update and return (old or new based on returnNew) | | deleteMany(query) | Promise<number> | Delete matching documents, returns count | | deleteOne(query) | Promise<number> | Delete first match, returns 1 or 0 | | findOneAndDelete(query) | Promise<T \| null> | Delete first match, returns deleted doc | | countDocuments(query) | Promise<number> | Count matching documents |

QueryBuilder<T>

| Method | Returns | Description | |--------|---------|-------------| | sort(config) | QueryBuilder<T> | Sort by fields ({ field: 1 \| -1 }) | | skip(n) | QueryBuilder<T> | Skip n results | | limit(n) | QueryBuilder<T> | Limit to n results | | exec() | Promise<T[]> | Execute the query | | (thenable) | Promise<T[]> | Can be used with await directly |

connectRedis(url: string)

Connects to Redis and returns the client instance. Must be called before any model operations.