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.
Afficher le fichier Open project: leroy-merlin-br/mongolid Class Usage Examples

Protected Properties

Свойство Type Description
$bulkWrite MongoDB\Driver\BulkWrite
$options array
$schema Mongolid\Schema\Schema

Méthodes publiques

Méthode 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 méthode

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

execute() public méthode

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

getBulkWrite() public méthode

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

setBulkWrite() public méthode

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

updateOne() public méthode

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
Résultat MongoDB\Driver\BulkWrite

$options protected_oe property

protected array $options
Résultat array

$schema protected_oe property

protected Schema,Mongolid\Schema $schema
Résultat Mongolid\Schema\Schema