MCPcopy
hub / github.com/sequelize/sequelize / _conformInclude

Method _conformInclude

src/model.js:365–417  ·  view source on GitHub ↗
(include, self)

Source from the content-addressed store, hash-verified

363 }
364
365 static _conformInclude(include, self) {
366 if (include) {
367 let model;
368
369 if (include._pseudo) return include;
370
371 include = this._transformStringAssociation(include, self);
372
373 if (include instanceof Association) {
374 if (self && include.target.name === self.name) {
375 model = include.source;
376 } else {
377 model = include.target;
378 }
379
380 return { model, association: include, as: include.as };
381 }
382
383 if (include.prototype && include.prototype instanceof Model) {
384 return { model: include };
385 }
386
387 if (_.isPlainObject(include)) {
388 if (include.association) {
389 include.association = this._transformStringAssociation(include.association, self);
390
391 if (self && include.association.target.name === self.name) {
392 model = include.association.source;
393 } else {
394 model = include.association.target;
395 }
396
397 if (!include.model) include.model = model;
398 if (!include.as) include.as = include.association.as;
399
400 this._conformIncludes(include, model);
401 return include;
402 }
403
404 if (include.model) {
405 this._conformIncludes(include, include.model);
406 return include;
407 }
408
409 if (include.all) {
410 this._conformIncludes(include);
411 return include;
412 }
413 }
414 }
415
416 throw new Error('Include unexpected. Element has to be either a Model, an Association or an object.');
417 }
418
419 static _expandIncludeAllElement(includes, include) {
420 // check 'all' attribute provided is valid

Callers 2

_conformIncludesMethod · 0.95

Calls 2

_conformIncludesMethod · 0.95

Tested by

no test coverage detected