Check out v4 of the Fauna CLI
v4 of the Fauna CLI is now in beta. The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start. |
key.update()
Description
Updates a key, represented as an
Key
document, with fields from a
provided data object.
During the update, fields from the data object are copied to the document, creating new fields or updating existing fields. The operation is similar to a merge.
Nested fields
Fields with nested objects in the data object are merged with the identically named nested object in the document.
Metadata fields
You can’t use this method to insert or edit the following metadata fields:
-
id
-
coll
-
ts
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
data |
true |
Document fields for the For supported document fields, see
The object can’t include the following metadata fields: * |
Return value
Type | Description |
---|---|
The updated |
Examples
Key.byId("412655134325080576")!.update({
data: {
desc: "Admin key for prod app database"
}
})
{
id: "412655134325080576",
coll: Key,
ts: Time("2099-07-11T14:17:49.890Z"),
role: "admin",
data: {
desc: "Admin key for prod app database"
}
}
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!