meteor-collection-hooks icon indicating copy to clipboard operation
meteor-collection-hooks copied to clipboard

Circumventing hooks of CollectionFS

Open GhassenRjab opened this issue 7 years ago • 2 comments

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 avatar Aug 06 '17 07:08 GhassenRjab

@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

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

xet7 avatar Aug 12 '17 09:08 xet7

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.

zimme avatar Aug 12 '17 10:08 zimme