To store objects in Node.js redism we call the hmset
method.
For instance, we write
client.hmset("hosts", "mjr", "1", "another", "23", "home", "1234");
client.hgetall("hosts", (err, obj) => {
console.dir(obj);
});
to call hmset
with the key 'hosts'
and the subsequent arguments as key-value pairs.
Then we get the value with with key 'hosts'
with hgetall
.
We get the value from obj
in the callback.