redis-store-json
⚠️ i did a mistake on versionning last version is 1.1.0. I'm sorry about that
This module was at the beginning for a personal project, but I decided to publish it.
redis-store-json, is a light nodejs module that will allow to easily store, get and modify JSON object into redis database. It base on promise, so every function work with promise
Installation
npm --save install redis-store-json
You will also need the redis_nodejs package https://github.com/NodeRedis/node_redis
Getting started
Basic set-up
For more redis set-up option check https://github.com/NodeRedis/node_redis
const redisJson = ; //import the moduleconst redis = ; //import redis moduleconst client = redis; //create a new redis connection redisJson; //give the redis instance to redis-json-store let testSet = "testKey1" : "test" "testKey2" : "test2"redisJson // set a new JSON key
⚠️ Before using any function make sure to call .use() and give your redis connection instance
Documentation
Setting and modifying data
set(redisKey, payload)
return { Promise } if resolved successfully set data, reject error
Param
Name | Description |
---|---|
redisKey | The key of the redis table to modify |
payload | The JSON to store |
Example
...let testSet = "testKey1" : "test" "testKey2" : "test2"redisJson // set a new JSON key
modifyValueByJsonKey(redisKey, JSONkey, value)
modify a value of a JSON object stored on a DB
Param
Name | Description |
---|---|
redisKey | The key of the redis table to modify |
JSONkey | the JSON key stored on the JSON object to modify |
value | new value to set |
Example
...//testSet = {// "testKey1" : "test",// "testKey2" : "test2"//} // set the data to redis// ... redisJson
Getting data
getJSON(databaseKey)
return if resolved a new JSON object who contain the stored database informations
Param
Name | Description |
---|---|
databaseKey | The key of the redis table to get |
Example
...//testSet = {// "testKey1" : "test",// "testKey2" : "test2"//} // set the data to redis// ... redisJson
getValueByJsonKey(databaseKey, JSONkey)
return if resolved return the value of the key of the JSON object store in the DB
Param
Name | Description |
---|---|
databaseKey | The key of the redis table to get |
JSONkey | The JSON to get data from |
Example
...let testSet = "testKey1" : "test" "testKey2" : "test2"// set the data to redis redisJson
hasJSONkey(redisKey, JSONkey)
return if resolved return the value of the key of the JSON object store in the DB
Param
Name | Description |
---|---|
redisKey | The key of the redis table to get |
JSONkey | The JSON key to check |
Example
...let testSet = "testKey1" : "test" "testKey2" : "test2"// set the data to redis redisJson