Delete Documents

Mission

Delete operations remove documents permanently from the database.

The Payoff

By completing this module, you will understand how to run permanent purges using direct record IDs, single matched filters, and bulk query exclusions.

Estimated Time: 3 minutesModules: 3 Concepts
Capital Letter Constraint
Note the capital **D** in the method signature **`.DeleteById()`**. If you try to call lowercase `.deleteById()`, the compiler or runtime will throw a method exception.

Obtain target document ID

Specify the unique _id key of the document to purge.

Execute capitalized DeleteById

Call .DeleteById('id') to execute the database purge operation.
Interactive Code Snippet
typescript
const response = await sdk.collection("users").DeleteById("user_12345");if (response.success) {  console.log("Document purged successfully.");}

Declare query filters

Apply selector criteria using .where(field, operator, value).

Submit deleteOne

Invoke .deleteOne() to delete the first singular document matching the query scope.
Interactive Code Snippet
typescript
// Deletes the first user record matching this query filterawait sdk.collection("users")  .where("email", "=", "[email protected]")  .deleteOne();

Declare target filter criteria

Scope multiple target records using .where() filters.

Invoke deleteMany

Call .deleteMany() to purge all matching records from the collection permanently.
Interactive Code Snippet
typescript
// Deletes all users that are inactiveawait sdk.collection("users")  .where("status", "=", "inactive")  .deleteMany();