Delete Many

Deletes all the documents by a specified filter.

Use this API action when you request the mass deletion of your collection documents. You can set a filter to delete some portions of documents.

[DeleteMany] - Deletes all the documents by a specified filter.

delete

Use this API action when you request the mass deletion of your collection documents. You can set a filter to delete some portions of documents. https://docs.codemash.io/api/database/collections/delete-many

Authorizations
Path parameters
CollectionNamestringRequired

Collection name - unique, lowercased, collection name without whitespace. E.g., if your collection title you have entered in the CodeMash dashboard is "Business Trips" then collection name would be "business-trips".

versionstringRequired

The CodeMash API version used to fetch data from the API. If not specified, the last version will be used. E.g.: v2

Header parameters
AcceptanyRequired

Accept Header

X-CM-ClusterstringOptional

API key of your cluster. Can be passed in a header as X-CM-Cluster.

X-CM-ProjectIdstringRequired

ID of your project. Can be passed in a header as X-CM-ProjectId.

CultureCodestringOptional

Specify culture code when your response from the API should be localised. E.g.: en

Body
FilterstringOptional

Deletes all the documents by a specified filter (in JSON format).

IgnoreTriggersbooleanOptional

Ignore the delete trigger when executing mass deletion. When this property is set to "true", all delete triggers won't be executed.

Responses
200
Success
application/json
delete
DELETE //{version}/db/{CollectionName}/bulk HTTP/1.1
Host: api.codemash.io
Authorization: YOUR_API_KEY
X-CM-ProjectId: text
Content-Type: application/x-www-form-urlencoded
Accept: */*
Content-Length: 39

"Filter='text'&IgnoreTriggers=true"
200

Success

{
  "response_status": {
    "error_code": "text",
    "message": "text",
    "stack_trace": "text",
    "errors": [
      {
        "error_code": "text",
        "field_name": "text",
        "message": "text",
        "meta": {
          "ANY_ADDITIONAL_PROPERTY": "text"
        }
      }
    ],
    "meta": {
      "ANY_ADDITIONAL_PROPERTY": "text"
    }
  },
  "result": {
    "deletedCount": 1,
    "isAcknowledged": true
  }
}
var client = new CodeMashClient(apiKey, projectId);
var service = new CodeMashRepository<Person>(client);

await service.DeleteManyAsync(
    x => x.Name == "John"
);

Check the information about entities on how your filter parameters are mapped.

Last updated

Was this helpful?