Skip to main content

Delete Object(s)

Delete Object

You can delete an object(s) by calling the delete method.

info

The delete method is a destructive method. It deletes objects matching the query and returns information about the delete operation.

tip
  • Applicable query modifiers
    ✓ filter
    ✓ lookup
// Deletes an order identified by id '62064163ae99b3a645705667' from userOrders
const result = await altogic.db
.model("userOrders")
.filter('_id == "62064163ae99b3a645705667"')
.delete();

// Deletes orders where status equals to 'cancelled' from userOrders
const result = await altogic.db
.model("userOrders")
.filter('status == "cancelled"')
.delete();
Example response
{
"data": {
"totalMatch": 1,
"deleted": 1
},
"errors": null
}
note

If the client library key is set to enforce session, an active user session is required (e.g., user needs to be logged in) to call this method.