Registry / database / nohm
library3.0.0jsnpmunverified

Nohm is an ORM for Node.js and Redis, written in TypeScript with first-class typings. It supports standard ORM features (validate, store, search, sort, link/unlink, delete), dynamic relations defined at runtime, shared validations with the browser, and PubSub-based ORM events for live updates. The project is currently unmaintained (last release 3.0.0) and has known security vulnerabilities. It requires Redis >= 2.4 and Node >= 8.

npm install nohm
INSTALL
IMPORT
SIG · NOHM
N
nohm
databasejavascriptv3.0.0
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.

Nohm
import { Nohm } from 'nohm'
import nohm from 'nohm'
Nohm is a named export, not a default export. In v3 it's ESM-only.
NohmModel
import { NohmModel } from 'nohm'
const NohmModel = require('nohm').NohmModel
Use destructured import. CommonJS require still works but is deprecated.
ValidationError
import { ValidationError } from 'nohm'
ValidationError is exported for catching validation errors in try/catch blocks.

Shows ESM import of Nohm, NohmModel, ValidationError; Redis client creation; model class definition with static properties; model save with validation error handling.

import { Nohm, NohmModel, ValidationError } from 'nohm'; import { createClient } from 'redis'; const client = createClient({ url: process.env.REDIS_URL ?? 'redis://localhost:6379', }); class User extends NohmModel { get displayName() { return `${this.property('firstname')} ${this.property('lastname')}`; } } User.modelName = 'User'; User.definitions = { firstname: { type: 'string', validations: ['notEmpty'], }, lastname: { type: 'string', validations: ['notEmpty'], }, }; Nohm.setClient(client); Nohm.setPrefix('myapp'); async function main() { await Nohm.ready(); const user = new User({ firstname: 'John', lastname: 'Doe' }); try { await user.save(); console.log('Saved user with id', user.id); } catch (err) { if (err instanceof ValidationError) { console.error('Validation failed:', err.message); } else { console.error(err); } } await client.quit(); } main();
Debug
Known issues
breakingv3 is ESM-only. If you are using CommonJS (require), you must switch to dynamic import or upgrade to Node >= 16 with ESM support.
fix
Use import { Nohm } from 'nohm' or wrap require in a dynamic import: const { Nohm } = await import('nohm');
affects: 3.0.0
breakingThe 'redis' client must now be created using 'createClient()' and passed via 'Nohm.setClient()'. Old v2-style automatic connection is removed.
fix
Create a redis client with 'createClient()' and call 'Nohm.setClient(client)' before using models.
affects: 3.0.0
breakingNohmModel.definitions no longer accepts shorthand 'type' strings; all types must be explicit strings or functions.
fix
Use 'type: 'string'' instead of 'type: String' and ensure all definition objects are complete.
affects: 3.0.0
deprecatedThe 'nohm.model()' function is deprecated. Use ES6 class extending NohmModel instead.
fix
Define a class that extends NohmModel and set static modelName and definitions.
affects: >=3.0.0
gotchaDue to known vulnerabilities (Snyk badge shows high severity), be cautious when using in production.
fix
Evaluate alternatives like redis-om or ioredis based ORMs.
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'nohm'
Nohm v3 is ESM-only and requires Node >= 12 with --experimental-modules or Node >= 16.
fix
Update to Node >= 16 and use 'import { Nohm } from 'nohm'' or enable ESM via 'type': 'module' in package.json.
TypeError: Nohm.setClient is not a function
You might be importing the default export instead of the named export.
fix
Use correct import: import { Nohm } from 'nohm' instead of import Nohm from 'nohm'.
Redis client is not set. Call Nohm.setClient() before using models.
You forgot to set the redis client with Nohm.setClient() after import.
fix
Call Nohm.setClient(redisClient) immediately after creating the redis client.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
redisrequiredNohm requires the 'redis' package to connect to Redis. It uses redis client internals and expects the client to be created via 'redis.createClient()'.
Agent activity
4 hits · last 30 days
node
4
Resources
packagenohm
nohm — npm install nohm · libregistry