objection.js
objection.js copied to clipboard
I believe the function resolveModel is wrong, or receiving the wrong parameter on certain occasions
I'm experiencing an issue where, when executing a relatedQuery
for a ManyToManyRelation
I get the "is not a subclass of Model or a file path to a module that exports one. You may be dealing with a require loop. See the documentation section about require loops.".
Debugging the code I've noticed in the file lib/utils/resolveModel.js
the function resolveModel
checks if the first parameter, modelRef
, is an Objection.js model. In my case, the parameter modelRef
contains the Objection.js model inside the property default
of modelRef
. That is, isModelClass(modelRef.default) === true
.
I'm importing the models inside relationMappings
to avoid loops, in case you are wondering.
Did I just stumbled on a bug or am I doing something wrong that causes the resolveModel
to almost be correct?