sohaam
March 16, 2016, 1:07pm
1
Hello, there is a pattern in guide of how to extend collection with hooks on operations. Example from guide:
class TodosCollection extends Mongo.Collection {
insert(doc, callback) {
...
return super(doc, callback);
}
}
Is there a way to extend bulk operations with the same pattern? Maybe @tmeasday could help with this?
Which operation do you want to override? What API do you want?
I think you could do something similar, sure.
sohaam
March 17, 2016, 3:42am
3
Hello, I would like to override .rawCollection().initializeUnorderedBulkOp().insert
and I need to have some updated doc data to reuse it within hook. I have a problems to write correct syntax as I not very familiar with classes.
Ok, well you wouldn’t be able to override that (as it’s a property something buried a few levels deep).
But you can just do something like
class TodosCollection extends Mongo.Collection {
bulkInsert(..) {
this.rawCollection().initializeUnorderedBulkOp().insert(...)
}
}
1 Like
sohaam
March 17, 2016, 4:29am
5
Thank you, I understood the main direction.