Delete

Overview of collection delete methods

delete
Delete One

https://api.codemash.io/:version/db/:collectionName
Deletes a particular record from collection.
Request
Response
Request
Path Parameters
version
required
string
A version of API endpoint.
collectionName
required
string
The name of collection to delete a record from.
Headers
Authorization
required
string
Secret API key which belongs to your project or user. Not required if using cookies with session ID.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Body Parameters
filter
required
string
Filter document. Used to find the record to delete. More about filters follow the a below.
Response
200: OK
Returns a delete result.
{
"result": {
"isAcknowledged": true,
"deletedCount": 1
}
}
.NET
Node
.NET
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.

Node
import { db } from 'codemash';
export async function deleteEmployee(id) {
return await db.deleteRecord('employees', { _id: id });
}

Check the docs on how to form filters.

delete
Delete Many

https://api.codemash.io/:version/db/:collectionName/bulk
Deletes multiple records from collection.
Request
Response
Request
Path Parameters
version
required
string
A version of API endpoint.
collectionName
required
string
The name of collection to delete records from.
Headers
Authorization
required
string
Secret API key which belongs to your project or user. Not required if using cookies with session ID.
x-cm-projectid
required
string
Your project's ID. Can be passed as query parameter.
Body Parameters
filter
required
string
Filter document. Used to find records to delete. More about filters follow a link below.
Response
200: OK
Returns a delete result.
{
"result": {
"isAcknowledged": true,
"deletedCount": 5
}
}
.NET
.NET
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.

Check the docs on how to form filters.