From f2effc0ed13c86ec129e14fdeffb25b2fe22cd12 Mon Sep 17 00:00:00 2001 From: Fabrizio Fenoglio Date: Thu, 2 Jun 2016 13:14:19 +0100 Subject: [PATCH] Added name of the relation into relations info --- lib/model.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/model.js b/lib/model.js index 4e1a3161..b46ccf9f 100644 --- a/lib/model.js +++ b/lib/model.js @@ -398,7 +398,8 @@ Model.prototype.hasOne = function(joinedModel, fieldDoc, leftKey, rightKey, opti model: joinedModel, leftKey: leftKey, rightKey: rightKey, - type: 'hasOne' + type: 'hasOne', + name: fieldDoc } joinedModel._getModel()._localKeys[rightKey] = true; @@ -441,7 +442,8 @@ Model.prototype.belongsTo = function(joinedModel, fieldDoc, leftKey, rightKey, o model: joinedModel, leftKey: leftKey, rightKey: rightKey, - type: 'belongsTo' + type: 'belongsTo', + name: fieldDoc }; self._getModel()._localKeys[leftKey] = true; @@ -450,6 +452,7 @@ Model.prototype.belongsTo = function(joinedModel, fieldDoc, leftKey, rightKey, o leftKey: leftKey, rightKey: rightKey, type: 'belongsTo', + name: fieldDoc } options = options || {}; @@ -500,7 +503,8 @@ Model.prototype.hasMany = function(joinedModel, fieldDoc, leftKey, rightKey, opt model: joinedModel, leftKey: leftKey, rightKey: rightKey, - type: 'hasMany' + type: 'hasMany', + name: fieldDoc }; joinedModel._getModel()._localKeys[rightKey] = true; @@ -571,7 +575,8 @@ Model.prototype.hasAndBelongsToMany = function(joinedModel, fieldDoc, leftKey, r rightKey: rightKey, type: 'hasAndBelongsToMany', link: link, - linkModel: linkModel + linkModel: linkModel, + name: fieldDoc } joinedModel._getModel()._reverseJoins[self.getTableName()] = { @@ -579,7 +584,8 @@ Model.prototype.hasAndBelongsToMany = function(joinedModel, fieldDoc, leftKey, r rightKey: rightKey, type: 'hasAndBelongsToMany', link: link, - linkModel: linkModel + linkModel: linkModel, + name: self.getTableName() } if (options.init !== false) {