Say I have a mongoose model m.
This model mwas created using a scheme sthat adds a method to register things:
s.methods.log = function(s) {
this.theLogger(s);
}
theLogger should be served at any time, so I feed theLogger as fast as possible.
It works:
const x = await m.findOne({_id: ...});
x.log("something");
The problem is that this will not work:
const x = new m();
x.log("something");
Is it possible to catch the moment xwith the help of the operator new?
source
share