Question
I am using a Redis database with Node.js. Using client.hmset("jobs", "jobId_12345", JSON.stringify(jsonJob))
I store JSON stringified jobs.
Now I want to iterate over all jobs and retrieve both job id and stringified job.
I tried client.hkeys("jobs", function (err, replies) {}
but that only
retrieves the keys.
I tried client.hgetall("jobs", function (err, obj) {}
but I don't know how
to retrieve both key and value from obj.
Any help is greatly appreciated because I'm stuck.
Answer
This is how it works. id in the code below is the record id.
redisclient.hgetall(key, function (err, dbset) {
// gather all records
for (id in dbset) {
...
}
});