Delete
Overview of collection delete methods
delete
https://api.codemash.io
/:version/db/:collectionName
Delete One
.NET
Node
PHP
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.
import { db } from 'codemash';
โ€‹
export async function deleteEmployee(id) {
return await db.deleteRecord('employees', { _id: id });
}
use Codemash\CodemashClient;
use Codemash\CodemashDb;
โ€‹
class CodemashService
{
protected CodemashDb $codemashDb;
protected string $collectionName = '{YOUR_COLLECTION_NAME}';
โ€‹
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
โ€‹
$client = new CodemashClient($secretKey, $projectId);
$this->codemashDb = new CodemashDb($client);
}
โ€‹
public function deleteOne()
{
$responseData = $this->codemashDb->deleteOneWithFilter([
'collectionName' => 'employees',
'filter' => [
'email' => '[email protected]',
],
]);
}
}
Check the docs on how to form filters.
delete
https://api.codemash.io
/:version/db/:collectionName/bulk
Delete Many
.NET
Node
PHP
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.
โ€‹
use Codemash\CodemashClient;
use Codemash\CodemashDb;
โ€‹
class CodemashService
{
protected CodemashDb $codemashDb;
protected string $collectionName = '{YOUR_COLLECTION_NAME}';
โ€‹
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
โ€‹
$client = new CodemashClient($secretKey, $projectId);
$this->codemashDb = new CodemashDb($client);
}
โ€‹
public function deleteMany()
{
$client = new CodemashClient('{YOUR_SECRET_KEY}', '{YOUR_PROJECT_ID}');
$codemashDb = new CodemashDb($client);
$responseData = $this->codemashDb->deleteMany([
'collectionName' => 'employees',
'filter' => [
'address' => 'New York',
],
]);
}
}
Check the docs on how to form filters.
Last modified 1yr ago
Copy link
On this page
delete
Delete One
delete
Delete Many