Node-red-contrib-redis, help with JSON.set and argument format

Hello,

This is the module I'm I'm using

I'm familiar with Redis and have successfully set up Publish and Subscribe workflows.

Also, I successfully set up LPUSH and RPOPLPUSH workflows.

By default, Redis stores information as a key-value pair where the value is a string, and I've been serializing JSON to a string for this.

I now need to start working with JSON. Objects in Redis, I have a Redis Stack server running with the JSON module and can set and get JSON in the redis-cli.

JSON.SET 'JBV315EByZ3blpuIOf26' $ '{"index":"audit-trail","documentId":"JBV315EByZ3blpuIOf26","timestamp":"2024-09-09T15:46:13.671Z","event":{"nodeId":"5","filespace":"lucid.blansys","filespaceUuid":"7e9bee12-f4c2-4a8b-b494-5cf69fbbec2e"},"source":{"offset":"1640","filename":"/media/lucidlink/.lucid_audit/5/2024/09/2024-09-09T15.34.23Z.log.active"},"operation":{"action":"Move","entryPath":"/image019.jpeg","fileId":"5:10098"},"device":{"hostName":"Deans-MacBook-Pro.local","osVersion":"23.6.0","osName":"Darwin"},"user":{"name":"DeanHolmes","id":"eb5eb7b2-7a33-45d5-b8ee-2ba254038712"},"target":{"destination":"","process":"new","lastupdate":""}}'

I'm trying the same through the Node-Red Redis plugin, I have tried many permutations of the arguments and get the same error.

"ReplyError: ERR wrong number of arguments for 'json.set' command"

I have tried sending the payload as

[
    '{{{documentID}}}',
    '$'
    '{{{payload}}}'
]

I have sent the key under msg,topic and payload

[
    '$',
    '{{{payload}}}'
]

I have tried without the root '$,' and I always have the same error.

I have tried setting some of the params in the module prefs

Screenshot 2024-09-12 at 2.31.39 PM

What redis node are you using seeing that there are 11 that can be found in the flow library.

I am unsure why this did not work during one of my tests, but I returned a couple of days later and got it working.

Using a function node

let jsonPayload = JSON.stringify(msg.payload);

msg.payload = [];
msg.payload.push("indx:sys:" + msg.documentID);
msg.payload.push("$");
msg.payload.push(jsonPayload);
return msg;

Then used a redis cmd connector

Screenshot 2024-09-16 at 12.03.22 PM

All working now.

Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.