How can I pass the filed name to the relation method of a model?

'use strict';

const Model = use('App/Services/Model');
class Business extends Model {
  country(filedName) {
    return this.belongsTo('App/Models/Country', filedName ? filedName : 'countryId');
  }
}
module.exports = Business;
1 Like

It really should work like that since it’s just regular class method.

How are you calling it or does it give any error?