Home > Software design >  How to change the value of a sanity field
How to change the value of a sanity field

Time:05-21

So i want to change the value of a specific field called "likes"

Here is the schema:

//...
fields: [
          {
            name: "likes",
            title: "Likes",
            type: "number",
          }
]

I want to change the like count when a button is pressed. it should change the like count by 1.

How to change the value?

CodePudding user response:

You can use client.patch(doc).inc({likes: 1}).commit() to increment your likes field each time it's called.

  • Related