✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Example of updating a deeply nested document with @sanity/client ?

2 replies
Last updated: Sep 12, 2020
hi would anyone have a example of updating a deeply nested document with
@sanity/client
? the kind of stuff you find there https://www.sanity.io/docs/js-client but for objects nested 2 or 3 levels down?
Sep 11, 2020, 11:19 PM
I guess we should improve our docs here, but you can do
client.patch(_id).set({'path.to.nested.key': 'new-value'}).commit()
You can also do it in a transaction like this:
https://twitter.com/kmelve/status/1254470107369222147/photo/1
Sep 12, 2020, 7:50 AM
awesome thanks
Sep 12, 2020, 7:54 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?