Open patb23 opened 4 years ago
Found the reason - seems inversifyTracer is causing the issue. If I comment the following lines, I am able to use the mongoose model. Need help to understand the reason
const tracer = new InversifyTracer({filters: ["*:*", "!Mongo*", "!EventEmitter"],});
tracer.on('call', (callInfo: CallInfo) => {
console.log(`${callInfo.className} ${callInfo.methodName} `);
});
tracer.on('return', (returnInfo: ReturnInfo) => {
console.log(`${returnInfo.className} ${returnInfo.methodName} returned ${returnInfo.result} - ${returnInfo.executionTime}ms`);
});
tracer.apply(container);
I referred mongoose sample to build an express application with mongoose. Pasting the relevant section for brevity. I placed console.log in the
constructor
and in thefindById
. The model is correctly inferred at the time of binding but from within the findById, it is inferred as anonymous function because of which getting ' this.Model.findById is not a functio' error.screenshot when invoking findById. As can be seen,
this.Model
is 'anonymous'. Need help in understanding this behavior