redisnode-redisredisjsonredis-stack-server

Issue: Redis JSON CLI SET command to update a variable in object


[ { "senderID": "64d9c926c17fd183a93d5e35", "receiverID": "64d9c92dc17fd183a93d5e39", "timestamp": "2023-08-14T07:39:45.946Z", "content": "bru", "status": "delivered", "type": "chat", "messageID": "8188946b-67e4-4d86-a927-32842361825c" }, ... ]

JSON.SET rooms:64d9c926c17fd183a93d5e35-64d9c92dc17fd183a93d5e39 $[?(@.status=='sent')].status "'delivered'"

Redis JSON Query Image on redis cli

I do get that error - Invalid argument(s): closing quote must be followed by a space or nothing at all

I have tried the variations of delivered and sent mentioned in the query with double quotes, single quotes, and both for the sake of it

Wrong Query? idk


Solution

  • I think the problem is that your JSONPath has single quotes in it. Try wrapping it in double quotes. Like this:

    JSON.SET rooms:64d9c926c17fd183a93d5e35-64d9c92dc17fd183a93d5e39 "$[?(@.status=='sent')].status" '"delivered"'
    

    Also, I changed the string to use single quotes on the outside. Since double quotes are in JSON all over the place, I always wrap my JSON in single quotes. Just a good habit.