Meteor-Community-Packages / meteor-collection-hooks

Meteor Collection Hooks
https://atmospherejs.com/matb33/collection-hooks
MIT License
658 stars 90 forks source link

Circumventing hooks of CollectionFS #225

Open GhassenRjab opened 7 years ago

GhassenRjab commented 7 years ago

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?

xet7 commented 7 years ago

@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:

1) 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

2) Look at what would it take to replace CollectionFS https://github.com/wekan/wekan/pull/875

zimme commented 7 years ago

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.