InsertOne
in package
implements
Executable
Operation for inserting a single document with the insert command.
Tags
Interfaces, Classes, Traits and Enums
- Executable
Table of Contents
- $collectionName : string
- $databaseName : string
- $document : array<string|int, mixed>|object
- $options : array<string|int, mixed>
- __construct() : mixed
- Constructs an insert command.
- execute() : InsertOneResult
- Execute the operation.
- createBulkWriteOptions() : array<string|int, mixed>
- Create options for constructing the bulk write.
- createExecuteOptions() : array<string|int, mixed>
- Create options for executing the bulk write.
Properties
$collectionName
private
string
$collectionName
$databaseName
private
string
$databaseName
$document
private
array<string|int, mixed>|object
$document
$options
private
array<string|int, mixed>
$options
Methods
__construct()
Constructs an insert command.
public
__construct(string $databaseName, string $collectionName, array<string|int, mixed>|object $document[, array<string|int, mixed> $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
- $databaseName : string
-
Database name
- $collectionName : string
-
Collection name
- $document : array<string|int, mixed>|object
-
Document to insert
- $options : array<string|int, mixed> = []
-
Command options
Tags
Return values
mixed —execute()
Execute the operation.
public
execute(Server $server) : InsertOneResult
Parameters
- $server : Server
Tags
Return values
InsertOneResult —createBulkWriteOptions()
Create options for constructing the bulk write.
private
createBulkWriteOptions() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —createExecuteOptions()
Create options for executing the bulk write.
private
createExecuteOptions() : array<string|int, mixed>