I use the oplog in Mongoose similar to Tim Oxley's example (https://gist.github.com/timoxley/1502645).
I am looking for an efficient way to turn a newly inserted document (oplog 'i' operation) into a Mongoose document.
I tried this:
var my_model = mongoose.model('test_doc', my_schema);
// ...
function oplog_receiver(op, doc) {
if( op === 'i' ) {
doc = new my_model(doc);
doc.isNew = false;
}
// ...
doc.modified_at = new Date();
doc.save(err => {});
}
That worked well.
Is this the way to go or is there a better way of doing this?
Many thanks,
Roman