Operation for deleting a single document with the delete command.
- Full name:
\MongoDB\Operation\DeleteOne
- This class implements:
\MongoDB\Operation\Executable
,\MongoDB\Operation\Explainable
See Also:
- \MongoDB\Collection::deleteOne() -
- http://docs.mongodb.org/manual/reference/command/delete/ -
private \MongoDB\Operation\Delete $delete
Constructs a delete command.
public __construct(string $databaseName, string $collectionName, array|object $filter, array $options = []): mixed
Supported options:
-
collation (document): Collation specification.
-
hint (string|document): The index to use. Specify either the index name as a string or the index key pattern as a document. If specified, then the query system will only consider plans using the hinted index.
This is not supported for server versions < 4.4 and will result in an exception at execution time if used.
-
session (MongoDB\Driver\Session): Client session.
-
writeConcern (MongoDB\Driver\WriteConcern): Write concern.
Parameters:
Parameter | Type | Description |
---|---|---|
$databaseName |
string | Database name |
$collectionName |
string | Collection name |
$filter |
array|object | Query by which to delete documents |
$options |
array | Command options |
Execute the operation.
public execute(\MongoDB\Driver\Server $server): \MongoDB\DeleteResult
Parameters:
Parameter | Type | Description |
---|---|---|
$server |
\MongoDB\Driver\Server |
See Also:
- \MongoDB\Operation\Executable::execute() -
Returns the command document for this operation.
public getCommandDocument(\MongoDB\Driver\Server $server): array
Parameters:
Parameter | Type | Description |
---|---|---|
$server |
\MongoDB\Driver\Server |
See Also:
- \MongoDB\Operation\Explainable::getCommandDocument() -