Package meteor-collection-hooks doesn't allow async function in the find hook

The package of collection hooks is very powerful and helpful to centralize some policies to access data and who can change them. I’m using it in the version 1.3.2 to apply some view policies for my documents.

In the new version, 2.0.0, there is a block that doesn’t allow using async function in the .before.find() . So, I’m looking for a solution to get some extra data from an user for my scenario.

My definition is something like this:

MyCollection.before.find(async function (userId, selector, options) {
        const user = await Meteor.userAsync();
        if (!user) {
            return;
        }
        selector.organizationOwner = { '$in': user.organizationHierarchy };
});

So, for my case, I need to get an extra info from User, so I cannot use just the userId. The idea is get some extra info from the user to add in the selector some extra conditions. This does an easy way to limit the access to data.

I didn’t figure out a way to get the user data sync without an async function.

Any ideas?

.find is a sync function which returns cursor, you can’t wait for an async function inside a sync one. I think it’s impossible to do so.