mongoid-history
mongoid-history copied to clipboard
Auditing BulkWrite in MogoDB
Hi, I successfully implemented this gem for document create, update and destroy.
But I am doing a Bulk Write operation in my program and the history tracker is not able to track those changes.
Does mongoid-history support Bulk Write? If yes, how should it be implemented and if no what can be done to make it track all Bulk write operations.
Thanks
How do you do a bulk insert? If it's via collection.insert
, you're effectively bypassing Mongoid and going to the MongoDB ruby driver, so there're no callbacks as far as I know.
bulk = Mongo::BulkWrite.new(ModelName.collection, insertdata, ordered: false) bulk.execute
I am using the above query, where insertdata is an array containing data to be written!
I am using Mongo::BulkWrite as you can see.
Oh that's new, I've never used it. I think for a bulk write we'd want a bulk history update, so some kind of extension that goes over documents, figures out the tracked data, appends it to insertdata, then bulk inserts it.