Redis › RedisJSON

How do you work with arrays within a JSON document stored in Redis, such as adding a new item to an existing array?

Intermediate

Answer

You use JSON.ARRAPPEND to add one or more new items to the end of an existing array at a specified path within your JSON document, letting you efficiently grow an array, such as a list of tags or order items, without needing to retrieve, modify, and rewrite the entire containing document.
JSON.ARRAPPEND product:55 $.tags '"electronics"'
Real-world example A product catalog system appends a new tag to a specific product's existing tags array directly within its stored JSON document, without needing to fetch and rewrite the entire product record just to add one tag.

Common follow-ups: What other array manipulation commands does RedisJSON provide besides append?;How do you remove a specific item from an array by its position?