Delete

Deletes one document by a specified document id or filter.

Use this API method when you want to find one document by a specified filter or id and delete it. If many documents are found, only the first one will be deleted.

[DeleteOne] - Deletes one document by a specified document id.

delete

Delete one document by its id. Please do not specify any filter if you want to delete by id. If filter is specified, then id is ignored. https://docs.codemash.io/api/database/collections/delete

Authorizations
Path parameters
IdstringRequired

Id of a record to delete. Required if filter is empty.

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

Set the filter (in JSON format) to delete the first document found in the collection. Required when Id is not set.

IgnoreTriggersbooleanOptional

Ignore the delete trigger when executing one document 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}/{Id} 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.DeleteOneAsync(
    x => x.Id == "record_id"
);

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

Check the docs on how to form filters.

Last updated

Was this helpful?