Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanity client: updating a field on an object #131

Open
fostimus opened this issue Feb 16, 2023 · 1 comment
Open

Sanity client: updating a field on an object #131

fostimus opened this issue Feb 16, 2023 · 1 comment

Comments

@fostimus
Copy link

Is your feature request related to a problem? Please describe.
I'm using sanity client to update one field on an object. The only way to update the object is via client.patch('id').set(fieldName: value}), but when value is an object, it overwrites the entire object on the document. Only the field specified would be nice.

Describe the solution you'd like
If an object field is set in the client, only update the fields specified in the object. Don't overwrite the entire object.

Additional context
I'd get by if I had access to the publish action's draft, so I could use the spread operator to create the correct object. Something like:

  1. get the most recent draft of the document
  2. Use the client to patch the document like: client.patch('id').set(article: { ...article, publishDate: <new date> })
@rexxars
Copy link
Member

rexxars commented Feb 18, 2023

Transferring this to the @sanity/client repository

@rexxars rexxars transferred this issue from sanity-io/sanity Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants