FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date. For more details, review the migration guide. Contact support@fauna.com with any questions. |
Delete
This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics. |
Delete( ref )
delete( ref )
Delete( ref )
Delete( ref )
Delete( ref )
Description
The Delete
function removes a document. This includes user-created
documents, plus system documents for Collections, Indexes, Databases,
etc.
When you delete a Database, all of its documents, Collections, child Databases, Functions, Indexes, Keys, Roles, and Tokens are also deleted.
When you delete a Collection, all documents within the Collection are also deleted.
When you delete a Collection that is the single source for an index, the index is also deleted.
There is no cascading delete for user-defined documents. If you have a document "A" that includes a reference to another document "B", deleting "A" does not affect "B", and deleting "B" does not affect "A". You would have to write your own query logic to automatically follow references to perform a cascading delete.
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 |
The Reference to an object that should be removed. |
Returns
An object representing the just-deleted document, containing all of the document’s fields and values.
All deleted documents return the following fields:
Field Name | Field Type | Definition and Requirements |
---|---|---|
|
Reference |
The reference to the now-deleted document. |
|
Long |
The timestamp of the most recent update of the document, prior to its deletion. |
All document fields are returned, but documents can have varying sets of
fields. For example, not all documents have a data
field; those
documents that do not contain a data
field do not return a data
field
upon deletion.
Examples
The following query removes the document pointed at by the reference:
{
ref: Ref(Collection("spells"), "181388642581742080"),
ts: 1592054525870000,
data: { name: "Mountain's Thunder", element: 'air', cost: 15 }
}
{'ref': Ref(id=181388642581742080, collection=Ref(id=spells, collection=Ref(id=collections))), 'ts': 1592857155330000, 'data': {'name': "Mountain's Thunder", 'element': 'air', 'cost': 15}}
map[data:map[cost:15 element:air name:Mountain's Thunder] ref:{181388642581742080 0xc00012c2a0 0xc00012c2a0 <nil>} ts:1603747152880000]
ObjectV(ref: RefV(id = "181388642581742080", collection = RefV(id = "spells", collection = RefV(id = "collections"))),ts: LongV(1603756243560000),data: ObjectV(name: StringV(Mountain's Thunder),element: StringV(air),cost: LongV(15)))
{
ref: Ref(Collection("spells"), "181388642581742080"),
ts: 1624310394670000,
data: { name: "Mountain's Thunder", element: 'air', cost: 15 }
}
After deletion, the document can no longer be retrieved:
Error: [NotFound] instance not found: Document not found.
ErrorData(code='instance not found', description='Document not found.', position=[], failures=None)
Response error 404. Errors: [](instance not found): Document not found., details: []
ERROR: instance not found: Document not found.
{
errors: [
{
position: [
'do',
1
],
code: 'instance not found',
description: 'Document not found.'
}
]
}
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!