Optional
asThe alias of the association. Used along with model.
This must be specified if the association has an alias (i.e. "as" was used when defining the association).
For hasOne
/ belongsTo
, this should be the singular name, and for hasMany
/ belongsToMany
,
it should be the plural.
using "as" is the same as using association because "as" is always the name of the association.
Optional
associationThe association you want to eagerly load. Either one of the values available in associations, or the name of the association.
This can be used instead of providing a model/as pair.
This is the recommended method.
Optional
attributesIf an array: a list of the attributes that you want to select.
Attributes can also be raw SQL (literal
), fn
, and col
To rename an attribute, you can pass an array, with two elements:
literal
, fn
, col
),If include
is used: selects all the attributes of the model,
plus some additional ones. Useful for aggregations.
{ attributes: { include: [[literal('COUNT(id)'), 'total']] }
If exclude
is used: selects all the attributes of the model,
except the one specified in exclude. Useful for security purposes
{ attributes: { exclude: ['password'] } }
Optional
duplicatingMark the include as duplicating, will prevent a subquery from being used.
Optional
includeLoad further nested related models
Optional
limitLimit include.
Only available when setting separate to true.
Optional
modelThe model you want to eagerly load.
This option only works if this model is only associated once to the parent model of this query. We recommend specifying association instead.
Optional
onCustom ON
clause, overrides default.
Optional
orWhether to bind the ON and WHERE clause together by OR instead of AND.
false
Optional
orderOrder include. Only available when setting separate
to true.
Optional
paranoidIf true, only non-deleted records will be returned. If false, both deleted and non-deleted records will be returned.
Only applies if paranoid is true for the model.
true
Optional
requiredIf true, converts to an inner join, which means that the parent model will only be loaded if it has any matching children.
True if include.where
is set, false otherwise.
Optional
rightIf true, converts to a right join if dialect support it.
Incompatible with required.
Optional
separateIf true, runs a separate query to fetch the associated instances.
false
Optional
subUse sub queries. This should only be used if you know for sure the query does not result in a cartesian product.
Optional
throughThrough Options
Optional
whereWhere clauses to apply to the child model
Note that this converts the eager load to an inner join, unless you explicitly set required to false
Generated using TypeDoc
Complex include options