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:

Product.byId("392886847463751746")!.delete()
Product("394078621888675904")  /* not found */

The document doesn’t exist:

Product.byId("392886847463751746")!.delete()
document_not_found

error: Collection `Product` does not contain document with id 392886847463751746.
at *query*:1:13
  |
1 | Product.byId("392886847463751746")!.delete()
  |             ^^^^^^^^^^^^^^^^^^^^^^^
  |

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!