-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Problem descriptions
Relations cannot be fetched due to a bug.
core.es5.js:1020 ERROR TypeError: Cannot read property 'makeHasManyLocalKeys' of undefined
at js-data-localstorage.js:1221
at Array.forEach (<anonymous>)
at js-data-localstorage.js:1220
at LocalStorageAdapter.loadHasManyLocalKeys (js-data-localstorage.js:1245)
at js-data-localstorage.js:1109
at Object._forRelation (js-data.js:250)
at js-data.js:894
at Array.forEach (<anonymous>)
at Object.forEachRelation (js-data.js:893)
at js-data-localstorage.js:1100
The line of code causing the issue:
loadHasManyLocalKeys: function loadHasManyLocalKeys(mapper, def, records, __opts) {
var self = this;
var record = void 0;
var relatedMapper = def.getRelation();
if (jsData.utils.isObject(records) && !jsData.utils.isArray(records)) {
record = records;
}
if (record) {
return self.findAll(relatedMapper, {
where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, {
'in': self.makeHasManyLocalKeys(mapper, def, record)
})
}, __opts).then(function (relatedItems) {
def.setLocalField(record, relatedItems);
});
} else {
var _ret2 = function () {
var localKeys = [];
records.forEach(function (record) {
localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record));
});
return {
v: self.findAll(relatedMapper, {
where: babelHelpers.defineProperty({}, relatedMapper.idAttribute, {
'in': unique(localKeys).filter(function (x) {
return x;
})
})
}, __opts).then(function (relatedItems) {
records.forEach(function (item) {
var attached = [];
var itemKeys = jsData.utils.get(item, def.localKeys) || [];
itemKeys = jsData.utils.isArray(itemKeys) ? itemKeys : Object.keys(itemKeys);
relatedItems.forEach(function (relatedItem) {
if (itemKeys && itemKeys.indexOf(relatedItem[relatedMapper.idAttribute]) !== -1) {
attached.push(relatedItem);
}
});
def.setLocalField(item, attached);
});
return relatedItems;
})
};
}();
if ((typeof _ret2 === 'undefined' ? 'undefined' : babelHelpers.typeof(_ret2)) === "object") return _ret2.v;
}
},
localKeys = localKeys.concat(self.self.makeHasManyLocalKeys(mapper, def, record));
Self is declared twice (like 1221 in the npm version of the 3.0.1beta2). The current this scope has no variable called self.
Removing one of the duplicate selfs has resolved my issue,
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels