javascript - redis client and node js - hgetall method fails with empty results -


this day 1 me redis cilent , node js.

i'm trying replicate command run via redis-cli in node.js:

127.0.0.1:6379> hgetall widgets:9145090003_00:00_00:00 1) "id" 2) "33305" 3) "loc" 4) "jamaica" 5) "days" 6) "" 

here's nodejs code:

client.hgetall("widgets:9145090003_00:00_00:00", function (err, replies) {         console.log(err);         replies.foreach(function (reply,i) {                 console.log('  ' + + ':' + reply);         });  }); 

it comes null , fails while trying foreach.

i tried:

 client.hgetall("widgets", function (err, replies) {             console.log(err);             replies.foreach(function (reply,i) {                     console.log('  ' + + ':' + reply);             });      }); 

but same result.

not sure i'm doing wrong.

edit 1

i tried code:

 17 console.log("attempting hgetall..");  18 client.hgetall("widgets:9145090003_00:00_00:00", function (err, replies) {  19         //for (let k in replies) console.log(' ${k}:${replies[k]}');  20         console.log(replies.id);  21 }); 

and here results:

/var/www/html/node/test/models/widgets.js:20     console.log(replies.id);                        ^  typeerror: cannot read property 'id' of null 

and yet, in cli can this:

127.0.0.1:6379> hget widgets:9145090003_00:00_00:00 id "33305" 127.0.0.1:6379> hgetall widgets:9145090003_00:00_00:00 1) "id" 2) "33305" 3) "loc" 4) "jamaica" 5) "days" 6) "" 127.0.0.1:6379>  

the reply of hgetall of type object, try adding following line code

console.log(replies.id); 

and print 33305 in console.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -