stockholmux/node_redis-rejson

client.json_mget array parameter issue

teddybee opened this issue · 1 comments

I would like to fetch multiple objects with mget, I get the key array from zrange. Somehow I unable to get it work, even if I put a param as is or wrap it in a JSON.stringify() method.
Here is my part of code:

redisdb.zrange(KEYBASE, 0, 50, (err,indexes) =>{
          if (err) throw(err);
          console.log("indexes: " + JSON.stringify(indexes));          
                    
          redisdb.json_mget(indexes, '.' ,(err,list) =>{
            if (err) throw(err);
            console.log(list);
          });
        });   

If I exchange the indexes param to indexes[4] it is working good, I got back an array with 1 item. With full array param (indexes) I get nothing, not even an exception.
With JSON.stringify(indexes) I get [ null ] .
Could you write an example query about mget with string ids?

In the redis-cli monitor I saw this log (in JSON.stringify case):
"json.mget" "["messages_default_1","messages_default_2","messages_default_3","messages_default_4","messages_default_5","messages_default_6","messages_default_7","messages_default_8","messages_default_9","messages_default_10","messages_default_11"]" "."

I figured it out. The input array is not an array, just a lot of individual string params.
This is working:
redisdb.json_mget(...indexes, '.', (err,list) => { }