chameleonbr / node-red-contrib-redis

Node RED client for Redis with pub/sub, list, lua scripting and other commands support.
MIT License
46 stars 40 forks source link

LRANGE command #56

Open lliendo opened 2 years ago

lliendo commented 2 years ago

I'm trying to issue an LRANGE command (syntax is LRANGE "KEY" START STOP, where START and STOP are integer values).

These are the things that I have tried:

1 - Create the node. I set the "Topic/Key" input to the desired key (in this case "collectedImages"). Then I set the START and STOP arguments as: [0, 9] in the "Params" box. I get an error reporting: "ReplyError: ERR wrong number of arguments for 'lrange' command".

Screenshot from 2022-05-05 17-54-04

2 - Create the node. I set the "Topic/Key" input to the desired key (in this case "collectedImages"). Then I set the KEY, START and STOP arguments as: ["collectedImages", 0, 9] in the "Params" box. I get an error reporting: "ReplyError: ERR wrong number of arguments for 'lrange' command".

Screenshot from 2022-05-05 17-54-33

It is super confusing how to correctly pass arguments for each command. Wouldn't it be much better and easier to let the user to completely construct the command from a function or set a string with the full command to run?

Thanks for your help!

innoagg commented 2 years ago

What are you injecting into the redis cmd node? Check your payload.

pauldeng commented 2 years ago

I agree, it is confusing.

But there is workaround: do NOT use the Topic/Key and Params fields in the redis cmd node.

Try this, hope it will be helpful to you:

[{"id":"a920473f2fb295af","type":"redis-command","z":"2c71e369871e1bf1","server":"a0efbb89.5e42d8","command":"LRANGE","name":"","topic":"","params":"[]","paramsType":"json","payloadType":"json","block":false,"x":420,"y":1280,"wires":[["4c9bf2a5755c6dfe"]]},{"id":"57d9021027774fc6","type":"inject","z":"2c71e369871e1bf1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"lkey\",\"0\", \"9\"]","payloadType":"json","x":190,"y":1280,"wires":[["a920473f2fb295af"]]},{"id":"4c9bf2a5755c6dfe","type":"debug","z":"2c71e369871e1bf1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":1280,"wires":[]},{"id":"a0efbb89.5e42d8","type":"redis-config","name":"local","options":"{}","cluster":false,"optionsType":"json"}]

This is opensource software, you are welcome to fork to fix it and PR back.

Cheers mate.