GithubHelp home page GithubHelp logo

Comments (7)

simonprickett avatar simonprickett commented on June 15, 2024

Do this at the same time as #60

from ru204.

simonprickett avatar simonprickett commented on June 15, 2024

This should go in the course in or just after section 1.4 - Updating Data with RedisJSON.

from ru204.

simonprickett avatar simonprickett commented on June 15, 2024

We should also update the code examples in section 2.2 to demonstrate this.

from ru204.

simonprickett avatar simonprickett commented on June 15, 2024

Command examples - remove author, change content of editions, update pages, add has_ebook_version:

127.0.0.1:6379> JSON.MERGE ru204:book:274 $ '{"pages": 350, "editions": [ "english", "spanish", "french"], "author": null, "has_ebook_version": true}'
OK

Add the author back, remove has_ebook_version:

127.0.0.1:6379> JSON.MERGE ru204:book:274 $ '{"author": "S.E. Grove", "has_ebook_version": null }'
OK

from ru204.

simonprickett avatar simonprickett commented on June 15, 2024

Also add example for when the key doesn't exist and when the path into the document doesn't exist but the document does.

from ru204.

simonprickett avatar simonprickett commented on June 15, 2024

Add a fragment of a new book (where the key didn't exist already):

Check if the book exists...

127.0.0.1:6379> EXISTS ru204:book:9999
(integer) 0

Demo that you can only merge into the root when the key doesn't exist yet:

127.0.0.1:6379> JSON.MERGE ru204:book:9999 $.metrics '{"rating_votes": 22}'
(error) ERR new objects must be created at the root

Create a partial new book there:

127.0.0.1:6379> JSON.MERGE ru204:book:9999 $ '{"author": "Redis", "id": "9999"}'

OK

Tidy up:

127.0.0.1:6379> DEL ru204:book:9999
(integer) 1

from ru204.

simonprickett avatar simonprickett commented on June 15, 2024

Also need to note that if you want to set a value to explicitly null you should use JSON.SET or JSON.MSET as JSON.MERGE will delete the value and its key completely.

from ru204.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.