Registry / database / loopback-connector-kv-redis

loopback-connector-kv-redis

JSON →
library4.0.0jsnpmunverified

The official LoopBack connector for Redis KeyValue operations. Version 4.0.0 runs on Node >=10 and has no recent releases (last update was Nov 2019). It is designed specifically for LoopBack 3 and not compatible with LoopBack 4. This connector supports key-value store patterns like TTL, expiration, and atomic operations. It differs from a generic Redis client by integrating with LoopBack's datasource and model infrastructure, enabling declarative configuration and ORM-like usage. However, it is effectively in maintenance mode as LoopBack 3 is EOL and no LoopBack 4 equivalent was published.

npm install loopback-connector-kv-redis
INSTALL
IMPORT
SIG · LOOPBACK-CONNECTOR
L
loopback-connector-kv-redis
databasejavascriptv4.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.

connector module
const connector = require('loopback-connector-kv-redis');
import connector from 'loopback-connector-kv-redis';
This package is CJS-only and has no ESM exports. Use require().
DataSource with KV connector
const DataSource = require('loopback-datasource-juggler').DataSource; const ds = new DataSource('kv-redis', { url: 'redis://localhost:6379' });
const ds = new DataSource('loopback-connector-kv-redis', {...});
The connector name passed to DataSource must be 'kv-redis', not the package name.
using KeyValue model
const MyModel = ds.define('MyModel', {name: String}, { kv: true }); MyModel.set('key', 'value');
const MyModel = ds.createModel('MyModel', {name: String});
Enable key-value behavior by setting `kv: true` in the model options. Without this, the model behaves as a regular database model and .set()/.get() will not be available.

Creates a LoopBack datasource using the kv-redis connector, defines a key-value model, and demonstrates basic operations: set, get, expire, ttl, delete.

const DataSource = require('loopback-datasource-juggler').DataSource; const ds = new DataSource('kv-redis', { url: process.env.REDIS_URL || 'redis://localhost:6379' }); const MyModel = ds.define('MyModel', { name: String }, { kv: true }); async function quickstart() { await MyModel.set('key1', 'value1'); const value = await MyModel.get('key1'); console.log(value); // 'value1' await MyModel.expire('key1', 10); // expire in 10 seconds console.log(await MyModel.ttl('key1')); // ~10 await MyModel.delete('key1'); console.log(await MyModel.get('key1')); // null await ds.disconnect(); } quickstart().catch(err => console.error(err));
Debug
Known issues
breakingLoopBack 3 is end-of-life. This connector is not compatible with LoopBack 4 and will not receive updates.
fix
Migrate to LoopBack 4 and use a different Redis client (e.g., ioredis) directly or via loopback-connector-redis (not kv).
affects: >=3.0.0 <=4.0.0
gotchaThe connector name must be 'kv-redis', not the npm package name.
fix
Always use 'kv-redis' as the first argument when creating a DataSource.
affects: <=4.0.0
gotchaModels must have `kv: true` in options to enable key-value methods.
fix
Add `{ kv: true }` as the third argument to ds.define().
affects: <=4.0.0
gotchaThe connector only works with a Redis instance that supports key-value operations. Sentinel or cluster mode may not be fully supported.
fix
Use a standalone Redis server or test with your topology.
affects: <=4.0.0
deprecatedThe package has not been updated since 2019. LoopBack 3 is deprecated and no longer maintained.
fix
Do not start new projects with LoopBack 3. Migrate to LoopBack 4 or other frameworks.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'loopback-connector-kv-redis'
The package is not installed, or the DataSource connector name is misspelled.
fix
Install the package: npm install loopback-connector-kv-redis. Then use connector name 'kv-redis'.
Error: Model is not a key-value model. Please set `kv: true` in model definition.
The model was defined without the `kv: true` option.
fix
Add `{ kv: true }` as the third argument to ds.define() when defining the model.
Error: connect ECONNREFUSED 127.0.0.1:6379
Redis server is not running or the connection URL is incorrect.
fix
Start Redis server or provide a valid REDIS_URL environment variable.
TypeError: MyModel.set is not a function
The model was not defined as a key-value model (missing `kv: true`) or the model wasn't fully initialized.
fix
Ensure model definition includes `{ kv: true }` and the datasource has connected before calling .set().
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies
loopback-datasource-jugglerrequiredProvides the base DataSource class and KeyValue mixin
redisrequiredOfficial Redis client for Node.js, used under the hood for all Redis operations
Agent activity
6 hits · last 30 days
node
4
Resources
loopback-connector-kv-redis — npm install loopback-connector-kv-redis · libregistry