PHP Класс 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.
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$bulkWrite MongoDB\Driver\BulkWrite
$options array
$schema Mongolid\Schema\Schema

Открытые методы

Метод Описание
__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.

Описание методов

__construct() публичный метод

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

execute() публичный метод

The collection is inferred from entity's collection name.
public execute ( integer $writeConcern = 1 ) : MongoDB\Driver\WriteResult
$writeConcern integer
Результат MongoDB\Driver\WriteResult

getBulkWrite() публичный метод

Get the BulkWrite object to perform other operations not covered by this class.
public getBulkWrite ( ) : MongoDB\Driver\BulkWrite
Результат MongoDB\Driver\BulkWrite

setBulkWrite() публичный метод

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

updateOne() публичный метод

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.
См. также: 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

Описание свойств

$bulkWrite защищенное свойство

protected BulkWrite,MongoDB\Driver $bulkWrite
Результат MongoDB\Driver\BulkWrite

$options защищенное свойство

protected array $options
Результат array

$schema защищенное свойство

protected Schema,Mongolid\Schema $schema
Результат Mongolid\Schema\Schema