Accessing Meteor context on the server inside overwritten Collection

I have overwritten the default collection that calls super insert/update/delete Collection calls.
However before calling i want to implement some security level that would automatically modify seloctor based on some logic.

export class CustomCollection extends Mongo.Collection {
    constructor(collectionName, useCustomModifier = false, omitLog = false) {
        this.useCustomModifier = useCustomModifier;
        this.omitLog = omitLog;

    find<T, U>(selector?: Selector<T> | ObjectID | string): Cursor<T, U> {
        const userId = this.userId(); //don't have access to Meteor context
        const sessionId =; //don't have access to Meteor context

       const companyId = extraLogic(userId, sessionId); //some custom logic to extract companyId, etc. that would be automatically inserted to the query

        return super.find( {...selector, companyId });


And then on the Meteor methods and publications i would just these CustomCollection.find({}).
The reason why i don’t want to pass the the context using “apply(this, …)” is because it would require alot of refactoring of the existing code and some parts could be missed out by accident or some developers would make error by directly calling leaving it a as possible error on human side.

export const myCollection =  new CustomCollection('myCollection ', false, true);

        'test': function () {
              //can access this.userId(), here but would like that inside find() and automatically

okey, i found similar thread to what i’m leaning for:

using Fibers as session storage might resolve my needs. So i’ll try to implement something around it.

also found out that fibers is going to get deprecated, so fibers sollution is out of the way for now. Will use method overwriting for now only.