Replace
This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics. |
Replace( ref, param_object )
replace( ref, param_object )
Replace( ref, param_object )
Replace( ref, param_object )
Replace( ref, param_object )
Replace( ref, param_object )
Description
The replace
operation substitutes the user data pointed to by the
reference with the data contained in the param_object
. Values not
specified in the param_object
are removed.
For performance, the documents describing AccessProviders, Databases,
Collections, Functions, Indexes, Keys, Roles, and Tokens use an object
cache. When you use This does not apply to non-schema documents, such as those in a user-created collection. Non-schema documents are always modified or removed in a strongly consistent manner. |
Parameters
Parameter | Type | Definition and Requirements |
---|---|---|
|
Reference |
A Reference to the document that should be modified. |
|
Object |
An Object that containing the document’s user data to be modified. See the following section for details. |
Returns
An Object containing the metadata about the replace
operations:
Field Name | Field Type | Definition and Requirements |
---|---|---|
|
Reference |
The Reference that identifies the document that was updated. |
|
Object |
A copy of the new document data. |
|
Long |
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:
{
ref: Ref(Collection("spells"), "181388642581742080"),
ts: 1592112569500000,
data: { name: "Mountain's Thunder", element: [ 'air', 'earth' ] }
}
{'ref': Ref(id=181388642581742080, collection=Ref(id=spells, collection=Ref(id=collections))), 'ts': 1592874029090000, 'data': {'name': "Mountain's Thunder", 'element': ['air', 'earth']}}
map[data:map[element:[air earth] name:Mountain's Thunder] ref:{181388642581742080 0xc000174180 0xc000174180 <nil>} ts:1603747275630000]
ObjectV(ref: RefV(id = "181388642581742080", collection = RefV(id = "spells", collection = RefV(id = "collections"))),ts: LongV(1603756703860000),data: ObjectV(name: StringV(Mountain's Thunder),element: Arr(StringV(air), StringV(earth))))
{ref: ref(id = "181388642581742080", collection = ref(id = "spells", collection = ref(id = "collections"))), ts: 1593467209080000, data: {name: "Mountain's Thunder", element: ["air", "earth"]}}
{
ref: Ref(Collection("spells"), "181388642581742080"),
ts: 1624310504150000,
data: { name: "Mountain's Thunder", element: [ 'air', 'earth' ] }
}