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.
delete
https://api.codemash.io/
/{version}/db/{CollectionName}/bulk
[DeleteMany] - 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. https://docs.codemash.io/api/database/collections/delete-many
Parameters
Path
CollectionName*
string
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".
version*
string
The CodeMash API version used to fetch data from the API. If not specified, the last version will be used. E.g.: v2
Header
X-CM-Cluster
string
API key of your cluster. Can be passed in a header as X-CM-Cluster.
X-CM-ProjectId*
string
ID of your project. Can be passed in a header as X-CM-ProjectId.
CultureCode
string
Specify culture code when your response from the API should be localised. E.g.: en
Accept*
string
Accept Header
Body
Filter
string
Deletes all the documents by a specified filter (in JSON format).
IgnoreTriggers
string
Ignore the delete trigger when executing mass deletion. When this property is set to "true", all delete triggers won't be executed.
Responses
200: OK
Success
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var service = new CodeMashRepository<Person>(client);
await service.DeleteManyAsync(
x => x.Name == "John"
);
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',
],
]);
}
}
Last modified 1yr ago