Objection.js: mapping.relation is not a function

Created on 13 Apr 2017  路  3Comments  路  Source: Vincit/objection.js

Getting a bunch of mapping.relation is not a function after project dependencies update (long time, 6+ months), is there perhaps a quick reason / suggested fix? Anyone encountered this? The models in my project are based on the ES7 documentation.

Most helpful comment

Just for others, I ran into this issue when I made a typo. I wrote Model.ManyToManyRElation. So this occurs (presumably; haven't glanced at the source) if you forget to define the relation field of a relation! Could probably do with an actual error message... Odd how specifying a function specifying a complex validation doesn't validate its arguments! :stuck_out_tongue:

All 3 comments

Are you using the old OneToOneRelation and OneToManyRelation types? They were deprecated and eventually removed. You should replace OneToOneRelation by BelongsToOneRelation and OneToManyRelation by HasManyRelation.

Yes, I think that's it! Thank you for the super quick response

Just for others, I ran into this issue when I made a typo. I wrote Model.ManyToManyRElation. So this occurs (presumably; haven't glanced at the source) if you forget to define the relation field of a relation! Could probably do with an actual error message... Odd how specifying a function specifying a complex validation doesn't validate its arguments! :stuck_out_tongue:

Was this page helpful?
0 / 5 - 0 ratings