Update specific field by using mutate useUpdate

Hi guys, I'm using mutate of useUpdate() to update a record on my db How can I just update a specific field of a record but still keep others fields?
kapa.ai
kapa.ai122d ago
Hi @Tan Dep Trai So 1. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- You can update a specific field of a record using the mutate method from useUpdate(). You need to pass the values prop to the mutate method, which contains the data that will be sent to the server. This values prop will be passed to the update method from the dataProvider as a parameter. Here is an example of how you can do it:
const { mutate } = useUpdate();

mutate({
id: 123, // the id of the record you want to update
values: {
fieldName: "New Value", // the field you want to update
},
});
const { mutate } = useUpdate();

mutate({
id: 123, // the id of the record you want to update
values: {
fieldName: "New Value", // the field you want to update
},
});
In this example, fieldName is the name of the field you want to update and "New Value" is the new value for that field. All other fields of the record will remain unchanged. For more information, you can refer to the useUpdate documentation (https://refine.dev/docs/data/hooks/use-update). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai122d ago
<@369510721135837184> kapa.ai is still learning and improving, please let us know how it did by reacting below