Moved inst initialization to place where it used
This commit is contained in:
parent
84dc39dfe2
commit
7b497eb58f
|
@ -845,7 +845,9 @@ Inclusion.include = function (objects, include, options, cb) {
|
|||
* @returns {*}
|
||||
*/
|
||||
function processTargetObj(obj, callback) {
|
||||
var inst = (obj instanceof self) ? obj : new self(obj);
|
||||
|
||||
var isInst = obj instanceof self;
|
||||
|
||||
// Calling the relation method on the instance
|
||||
if (relation.type === 'belongsTo') {
|
||||
// If the belongsTo relation doesn't have an owner
|
||||
|
@ -853,7 +855,7 @@ Inclusion.include = function (objects, include, options, cb) {
|
|||
defineCachedRelations(obj);
|
||||
// Set to null if the owner doesn't exist
|
||||
obj.__cachedRelations[relationName] = null;
|
||||
if (obj === inst) {
|
||||
if (isInst) {
|
||||
obj.__data[relationName] = null;
|
||||
} else {
|
||||
obj[relationName] = null;
|
||||
|
@ -867,7 +869,7 @@ Inclusion.include = function (objects, include, options, cb) {
|
|||
* @param cb
|
||||
*/
|
||||
function setIncludeData(result, cb) {
|
||||
if (obj === inst) {
|
||||
if (isInst) {
|
||||
if (Array.isArray(result) && !(result instanceof List)) {
|
||||
result = new List(result, relation.modelTo);
|
||||
}
|
||||
|
@ -885,6 +887,9 @@ Inclusion.include = function (objects, include, options, cb) {
|
|||
return setIncludeData(obj.__cachedRelations[relationName],
|
||||
callback);
|
||||
}
|
||||
|
||||
var inst = (obj instanceof self) ? obj : new self(obj);
|
||||
|
||||
//If related objects are not cached by include Handlers, directly call
|
||||
//related accessor function even though it is not very efficient
|
||||
var related; // relation accessor function
|
||||
|
|
Loading…
Reference in New Issue