meteor-collection-hooks
meteor-collection-hooks copied to clipboard
Circumventing hooks of CollectionFS
Based on #84 I could add hooks to CollectionFS
Attachments = new FS.Collection('attachments', ...);
Attachments.files.before.insert((userId, doc) => {});
Now, in some cases, I need to directly insert attachments without calling any hooks using direct. I first tried this instruction :
Attachments.direct.insert(attachment, () => {});
But it raised an exception Cannot read property 'insert' of undefined
.
And then tried this :
Attachments.files.direct.insert(attachment, () => {});
No exceptions were raised but the file was not added.
Is there any way I can use direct
and avoid CollectionFS hooks?
@GhassenRjab
When you get exception, does it mention where in CollectionFS code (file and line of code) it happends? It could be possible to add some option to bypass that hook.
Other alternatives:
- When looking at repo network https://github.com/matb33/meteor-collection-hooks/network
There is this code error try-catch code, I'm not sure is it related in any way: https://github.com/lawrentiy/meteor-collection-hooks/commit/0189c2528b68f212b7488439095fca49ea9f8f15
- Look at what would it take to replace CollectionFS https://github.com/wekan/wekan/pull/875
If any fixes are needed to resolve this I'm happy to accept a PR. I don't have time to look into this issue, but If I do I'll let you know.