Update
Update( ref, param_object )
Update( ref, param_object )
Update( ref, param_object )
Update( ref, param_object )
q.update( ref param_object )
Update( ref param_object )
Description
The Update
operation only modifies the specified fields in the
documents pointed to by ref
. Updates are partial, and only modify
values that are specified in the param_object
. Changes to scalar values
and arrays are entirely replaced by the new data. Modifications to
objects are merged. Setting a value to null
completely removes the
value. Fields in the document not specified in the param_object
are
not modified.
For performance, Databases, Collections, Functions, Indexes, Keys, and
Roles use a cache. When you use |
Parameters
Argument | Type | Definition and Requirements |
---|---|---|
|
A Reference identifying the document that should be modified. |
|
|
An Object containing the document data to update, as well as optional new credentials and delegates. See the following section for details. |
param_object
Field Name | Field Type | Definition and Requirements | ||
---|---|---|---|---|
|
The document’s user data to be modified. |
|||
|
The document’s credentials to be modified. |
|||
|
The document’s delegates to be modified. |
|||
|
Optional - A timestamp indicating the document’s time-to-live, which is when the document should be removed. When a document is removed, the document’s existence ceases (as if it never existed); temporal queries cannot recover the document.
|
Returns
An object containing the metadata about the update operations.
Field Name | Field Type | Definition and Requirements |
---|---|---|
|
The Reference that identifies the document that was updated. |
|
|
A copy of the new document data. |
|
|
The timestamp, with microsecond resolution, of the document update. |
Examples
The following query updates the document by changing the name
field to
the value "Mountains’s Thunder" and removing the cost
field from the
document. All other fields in the document remain unchanged.
ObjectV(ref: RefV(id = "181388642581742080", collection = RefV(id = "spells", collection = RefV(id = "collections"))),ts: LongV(1603756871700000),data: ObjectV(name: StringV(Mountain's Thunder),element: StringV(air)))
map[data:map[element:air name:Mountain's Thunder] ref:{181388642581742080 0xc000146180 0xc000146180 <nil>} ts:1603747313810000]
{ref: ref(id = "181388642581742080", collection = ref(id = "spells", collection = ref(id = "collections"))), ts: 1593467851740000, data: {name: "Mountain's Thunder", element: "air"}}
{
ref: Ref(Collection("spells"), "181388642581742080"),
ts: 1592112267090000,
data: { name: "Mountain's Thunder", element: 'air' }
}
{'ref': Ref(id=181388642581742080, collection=Ref(id=spells, collection=Ref(id=collections))), 'ts': 1592870397530000, 'data': {'name': "Mountain's Thunder", 'element': 'air'}}
{ref: ref(id = "181388642581742080", collection = ref(id = "spells", collection = ref(id = "collections"))), ts: 1594435307720000, data: {name: "Mountain's Thunder", element: "air"}}
Was this article helpful?
We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's Discourse forums
or email docs@fauna.com
Thank you for your feedback!