Skip to content

Commit

Permalink
Grab dictionary of models (w/ backwards compatibility)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikermcneil authored May 31, 2018
1 parent b35cc44 commit 9279d52
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/each-record-deep/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ module.exports = function eachRecordDeep(records, iteratee, arePhysical, modelId
throw new Error('Consistency violation: Expected `modelIdentity` to be a non-empty string. But instead, got: ' + util.inspect(modelIdentity, { depth: 5 }) + '');
}

// Grab dictionary of models (w/ backwards compatibility).
var models = orm.collections === undefined ? orm.collections : orm.models;

// Look up the Waterline model for this query.
// > This is so that we can reference the original model definition.
// var ParentWLModel = getModel(modelIdentity, orm);
var ParentWLModel = orm.collections[modelIdentity];
var ParentWLModel = models[modelIdentity];

// ┌─┐┌─┐┌─┐┬ ┬ ╦═╗╔═╗╔═╗╔═╗╦═╗╔╦╗ ┬┌┐┌ ┌─┐┬─┐┬─┐┌─┐┬ ┬
// ├┤ ├─┤│ ├─┤ ╠╦╝║╣ ║ ║ ║╠╦╝ ║║ ││││ ├─┤├┬┘├┬┘├─┤└┬┘
Expand Down Expand Up @@ -136,7 +138,7 @@ module.exports = function eachRecordDeep(records, iteratee, arePhysical, modelId

// Look up the live Waterline model referenced by this association.
var childModelIdentity = attrDef.model || attrDef.collection;
var ChildWLModel = orm.collections[childModelIdentity];
var ChildWLModel = models[childModelIdentity];

// If this attribute is a singular association...
if (attrDef.model) {
Expand Down

0 comments on commit 9279d52

Please sign in to comment.