lucid-mongo
lucid-mongo copied to clipboard
Model hooks won't work when library used stand-alone
Stack: TypeError: Cannot read property 'resolveFunc' of undefined at Hooks.exec (/Users/alexserdukov/Documents/Projects/Mobilunity/sites/mytransics/Tx-SystemAlarmsApi/node_modules/lucid-mongo/src/LucidMongo/Hooks/index.js:166:55)
The reason is that there are no working stub for forDir() method:
class Resolver {
forDir () {
}
}
I added in my project some workarounds for callbacks / arrow functions can be supported. Hope it helps for someone faced this issue, and I hope this workaround (or another solution) could be added to next releases.
const { resolver } = require("lucid-mongo/lib/iocResolver");
resolver.forDir = () => ({
resolveFunc: handler => {
if ('string' === (typeof handler)) {
throw new Error('References handlers aren\'t supported in stand-alone mode');
} else if ('function' !== (typeof handler)) {
throw new Error('Invalid handler passed');
}
return {method: handler};
}
});
Had the same issue, the workaround works. I think it would be great to make the standalone mode solid and bug-free. This ORM is much better compare to others I tested (with support for both relational dbs and Mongo).