delete()

Delete a document.

Signature

delete(): Null<collection> | NullCollectionDef

Description

The delete() method deletes the collection document or collection definition document from storage.

Parameters

None

Return value

Type Description

Null<collection>
NullCollectionDef

The method returns the query string followed by /* not found */ although, if successful, the document was found and deleted. See NullDoc

Examples

The document exists:

CoffeeBean.byId("375491155485261889")!.delete()
CoffeeBean.byId("375491155485261889") /* not found */

The document doesn’t exist:

CoffeeBean.byId("375491155485261889")!.delete()
document_not_found

error: Collection `CoffeeBean` doesn't contain document with id 375491155485261889.
at *query*:1:16
  |
1 | CoffeeBean.byId("375491155485261889")!.delete()
  |                ^^^^^^^^^^^^^^^^^^^^^^^
  |

Delete a collection definition document:

Collection.byName("testCollection00")!.delete()
Collection.byName("testCollection00") /* 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!