Operation for inserting a single document with the insert command.
- Full name:
\MongoDB\Operation\InsertOne
- This class implements:
\MongoDB\Operation\Executable
See Also:
- \MongoDB\Collection::insertOne() -
- http://docs.mongodb.org/manual/reference/command/insert/ -
private string $databaseName
private string $collectionName
private array|object $document
private array $options
Constructs an insert command.
public __construct(string $databaseName, string $collectionName, array|object $document, array $options = []): mixed
Supported options:
-
bypassDocumentValidation (boolean): If true, allows the write to circumvent document level validation.
-
session (MongoDB\Driver\Session): Client session.
-
writeConcern (MongoDB\Driver\WriteConcern): Write concern.
Parameters:
Parameter | Type | Description |
---|---|---|
$databaseName |
string | Database name |
$collectionName |
string | Collection name |
$document |
array|object | Document to insert |
$options |
array | Command options |
Execute the operation.
public execute(\MongoDB\Driver\Server $server): \MongoDB\InsertOneResult
Parameters:
Parameter | Type | Description |
---|---|---|
$server |
\MongoDB\Driver\Server |
See Also:
- \MongoDB\Operation\Executable::execute() -
Create options for constructing the bulk write.
private createBulkWriteOptions(): array
See Also:
Create options for executing the bulk write.
private createExecuteOptions(): array
See Also: