Check out v4 of the Fauna CLI
v4 of the Fauna CLI is now in beta. The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start. |
document.delete()
Learn: Documents |
---|
Delete a collection document.
Description
Deletes a collection document.
Examples
The document exists:
// Uses the `Product` collection's `byName()` index and
// the `first()` method to get a single document.
let product = Product.byName("cups").first()
product!.delete()
Product("111") /* deleted */
The document doesn’t exist:
Product.byId("12345")!.delete()
document_not_found: Collection `Product` does not contain document with id 12345.
error: Collection `Product` does not contain document with id 12345.
at *query*:1:13
|
1 | Product.byId("12345")!.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!