PHP Class Mongolid\DataMapper\BulkWrite

It's an incomplete and highly opinionated abstraction but yet flexible, since you are able to access the driver's API and can work with both ActiveRecord and DataMapper, since this class relies on the Schema and both classes implements HasSchemaInterface.
ファイルを表示 Open project: leroy-merlin-br/mongolid Class Usage Examples

Protected Properties

Property Type Description
$bulkWrite MongoDB\Driver\BulkWrite
$options array
$schema Mongolid\Schema\Schema

Public Methods

Method Description
__construct ( Mongolid\Schema\HasSchemaInterface $entity ) BulkWrite constructor.
execute ( integer $writeConcern = 1 ) : MongoDB\Driver\WriteResult Execute the BulkWrite, using a connection from the Pool.
getBulkWrite ( ) : MongoDB\Driver\BulkWrite Get the BulkWrite object to perform other operations not covered by this class.
setBulkWrite ( MongoDB\Driver\BulkWrite $bulkWrite ) Set BulkWrite object that will receive all operations and later be executed.
updateOne ( MongoDB\BSON\ObjectID | string $id, array $dataToSet, array $options = ['upsert' => true] ) Add an update operation to the Bulk, where only one record is updated, by _id.

Method Details

__construct() public method

BulkWrite constructor.
public __construct ( Mongolid\Schema\HasSchemaInterface $entity )
$entity Mongolid\Schema\HasSchemaInterface

execute() public method

The collection is inferred from entity's collection name.
public execute ( integer $writeConcern = 1 ) : MongoDB\Driver\WriteResult
$writeConcern integer
return MongoDB\Driver\WriteResult

getBulkWrite() public method

Get the BulkWrite object to perform other operations not covered by this class.
public getBulkWrite ( ) : MongoDB\Driver\BulkWrite
return MongoDB\Driver\BulkWrite

setBulkWrite() public method

Set BulkWrite object that will receive all operations and later be executed.
public setBulkWrite ( MongoDB\Driver\BulkWrite $bulkWrite )
$bulkWrite MongoDB\Driver\BulkWrite

updateOne() public method

Be aware that working with multiple levels of nesting on $dataToSet may have an undesired behavior that could lead to data loss on a specific key.
See also: https://docs.mongodb.com/manual/reference/operator/update/set/#set-top-level-fields
public updateOne ( MongoDB\BSON\ObjectID | string $id, array $dataToSet, array $options = ['upsert' => true] )
$id MongoDB\BSON\ObjectID | string
$dataToSet array
$options array

Property Details

$bulkWrite protected_oe property

protected BulkWrite,MongoDB\Driver $bulkWrite
return MongoDB\Driver\BulkWrite

$options protected_oe property

protected array $options
return array

$schema protected_oe property

protected Schema,Mongolid\Schema $schema
return Mongolid\Schema\Schema