Registry / database / modinha-redis

modinha-redis

JSON →
library0.1.0jsnpmunverified

RedisDocument mixin for Modinha models providing HTTP-semantic persistence methods backed by Redis hashes and sorted sets. v0.1.0 is a stable release from 2018 with 0.1.1 on GitHub. Designed for Node.js, it maps CRUD operations (list, get, insert, replace, patch, delete) onto Redis data structures and auto-generates unique/secondary index getters. The package adds _id, created, and modified fields to schemas. It is a thin, opinionated layer for Redis-backed document modeling, distinct from full ORMs.

npm install modinha-redis
INSTALL
IMPORT
SIG · MODINHA-REDIS
M
modinha-redis
databasejavascriptv0.1.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.

RedisDocument
import { RedisDocument } from 'modinha-redis'
var RedisDocument = require('modinha-redis').RedisDocument
CommonJS require works if using default Node.js; switch to ESM import in modern setups.
default
import modinhaRedis from 'modinha-redis'
undefined
No default export; only named export RedisDocument exists.
RedisDocument
const { RedisDocument } = require('modinha-redis')
const RedisDocument = require('modinha-redis')
require returns an object with RedisDocument property, not the mixin directly.

Shows how to define a Modinha model with unique/secondary indexes, extend with RedisDocument mixin, insert a record, and use auto-generated query methods.

// npm install modinha modinha-redis redis var Modinha = require('modinha'); var RedisDocument = require('modinha-redis').RedisDocument; var Account = Modinha.define('accounts', { email: { type: 'string', required: true, unique: true }, role: { type: 'string', secondary: true, enum: ['admin', 'editor', 'author'] }, hash: { type: 'string', private: true } }); // Extend model with Redis persistence Account.extend(RedisDocument); // Insert a new account Account.insert({ email: 'test@example.com', role: 'admin' }, function(err, result) { if (err) console.error(err); else console.log('Inserted:', result); }); // List by role Account.listByRole('admin', function(err, accounts) { if (err) console.error(err); else console.log('Admins:', accounts); }); // Get by unique email Account.getByEmail('test@example.com', function(err, account) { if (err) console.error(err); else console.log('Account:', account); });
Debug
Known issues
gotchaNo default export: require() returns an object, not the mixin directly.
fix
Use destructuring: const { RedisDocument } = require('modinha-redis');
affects: >=0.1.0
gotchaRedis client setup not included: The mixin expects a global redis client or environment variable; no built-in connection handling.
fix
Ensure redis.createClient() is called and available before using mixin.
affects: >=0.1.0
breakingVersion 0.1.0 may have breaking changes from earlier unpublished versions; check changelog.
fix
Review GitHub releases for breaking changes.
affects: =0.1.0
Errors
Common errors & fixes
TypeError: Account.extend is not a function
Account is not a Modinha model instance; missing Modinha.define() call.
fix
Ensure Account = Modinha.define('accounts', { ... }) before extending.
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Redis server is not running or not accessible.
fix
Start Redis server or set correct host/port via environment variables.
Cannot find module 'modinha-redis'
Package not installed or missing from node_modules.
fix
Run: npm install modinha-redis
TypeError: Cannot destructure property 'RedisDocument' of '...' as it is undefined
Incorrect import module; e.g., var { RedisDocument } = require('modinha') instead of modinha-redis.
fix
Use: const { RedisDocument } = require('modinha-redis');
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
modinharequiredRequired peer dependency; the mixin extends Modinha models.
redisrequiredRequired runtime dependency for Redis client.
Agent activity
2 hits · last 30 days
node
2
Resources
modinha-redis — npm install modinha-redis · libregistry