yii2-mongodb
yii2-mongodb copied to clipboard
`batchInsert` does not work with ActiveRecord models (probably)
Doc for \yii\mongodb\Collection::batchInsert()
says @param array $rows array of arrays or objects to be inserted
, but it doesn't work if you pass array of ActiveRecord into it. Probably because they fall straight into \MongoDB\Driver\BulkWrite::insert
at src/Command.php:225
, and ActiveRecord doesn't store any data in "real" properties, it stores it in "magic" properties.
Possible solution: use getAttributes()
if objects are instances of \yii\mongodb\ActiveRecord
before passing them to \MongoDB\Driver\BulkWrite::insert
.