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

Method _conformInclude

lib/model.js:342–394  ·  view source on GitHub ↗
(include, self)

Source from the content-addressed store, hash-verified

340 }
341
342 static _conformInclude(include, self) {
343 if (include) {
344 let model;
345
346 if (include._pseudo) return include;
347
348 include = this._transformStringAssociation(include, self);
349
350 if (include instanceof Association) {
351 if (self && include.target.name === self.name) {
352 model = include.source;
353 } else {
354 model = include.target;
355 }
356
357 return { model, association: include, as: include.as };
358 }
359
360 if (include.prototype && include.prototype instanceof Model) {
361 return { model: include };
362 }
363
364 if (_.isPlainObject(include)) {
365 if (include.association) {
366 include.association = this._transformStringAssociation(include.association, self);
367
368 if (self && include.association.target.name === self.name) {
369 model = include.association.source;
370 } else {
371 model = include.association.target;
372 }
373
374 if (!include.model) include.model = model;
375 if (!include.as) include.as = include.association.as;
376
377 this._conformIncludes(include, model);
378 return include;
379 }
380
381 if (include.model) {
382 this._conformIncludes(include, include.model);
383 return include;
384 }
385
386 if (include.all) {
387 this._conformIncludes(include);
388 return include;
389 }
390 }
391 }
392
393 throw new Error('Include unexpected. Element has to be either a Model, an Association or an object.');
394 }
395
396 static _expandIncludeAllElement(includes, include) {
397 // check 'all' attribute provided is valid

Callers 2

_conformIncludesMethod · 0.95

Calls 2

_conformIncludesMethod · 0.95

Tested by

no test coverage detected