Now, a service consists of many systems in production. As a result, some systems insert broken or invalid data to MongoDB.
Here is problem.
mongo-ruby-driver’s bulk-insert is dead or alive. If inserting docs has one invalid docuemnt, then insert operation failed. In addition, we can’t find invalid documents.
This behavior is not usable. We want to handle invalid documents, e.g. output to local file, ignoring documents and etc.
My pull request resolves this problem.
:collect_on_error to insert options.
result is an array of inserted document.
result is same as insert without
invalid_docs is an array of invalid document which removed ObjectId field.
We can handle invalid_docs manually.
For example, see fluent-plugin-mongo.
Enjoy MongoDB with Ruby!