yiisoft / yii2-mongodb

Yii 2 MongoDB extension
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
326 stars 191 forks source link

Active Record flexible batch operations(Insert,Update,Delete) #301

Open ziaratban opened 4 years ago

ziaratban commented 4 years ago
Q A
Is bugfix? no
New feature? yes
Breaks BC? no
Tests pass? yes
MyActiveRecord::$batchInsertSize = 1000;
foreach($myData as $data){
    $obj = new MyActiveRecord();
    $obj->field1 = 'data1';
    $obj->field2 = 'data2';
    $obj->field3 = 'data3';
    $obj->batchSave(); #or batchInsert();
    #no any database operation execute until count of insert operation equal MyActiveRecord::$batchInsertSize
}
MyActiveRecord::flushBatchInsert(); // executing the remaining operations. required.

or batchDelete() or batchUpdate

samdark commented 4 years ago

@ziaratban tests seems to fail: https://travis-ci.com/yiisoft/yii2-mongodb/jobs/293832598