updateData()
Update document data field contents.
Description
The updateData()
method updates the document data field with the
object fields and returns the updated document. During the update, object
fields are copied to the document data field, creating new fields or
updating existing fields. The operation is similar to a merge.
Only the fields included in object are updated, all other document fields aren’t updated. Fields with nested objects in object are merged with the identically named nested object in the document.
To remove a document field, set its value in object to null
.
Examples
-
Create a document with a data field:
{ id: "365648872630911009", coll: Books, ts: Time("2023-05-24T22:53:08.660Z"), name: "Then and Now", author: "W. Somerset Maugham", data: { data: "007571098 " } }
-
Update the data field:
{ id: "365648872630911009", coll: Books, ts: Time("2023-05-24T23:01:49.870Z"), name: "Then and Now", author: "W. Somerset Maugham", data: { data: "007571098", update: "fixed typo" } }
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!