Delete

Use delete() to remove a document from a collection using its _id.

🗑️ delete()

await db.users.delete("user_jianyang");

This deletes the document with _id: "user_jianyang" from the users collection.

Behavior

  • If the document exists, it's gone — permanently.
  • If it doesn't exist, it throws a 404 error.