postgrelize / IncludeOptions
Type Alias: IncludeOptions ​
IncludeOptions =
object
Defined in: src/associations/include.ts:44
One include entry (Sequelize v6 IncludeOptions): which association to load and how.
Name the association with model, as or association. Eager loading uses JOINs (see the guide), except separate, which runs another query.
See ​
Example ​
const opts: IncludeOptions = {
model: Post,
as: 'posts',
where: { published: true },
required: false,
attributes: ['id', 'title'],
include: [{ model: Tag }],
};
const users = await User.findAll({ include: [opts] });Properties ​
all? ​
optionalall?:boolean
Defined in: src/associations/include.ts:90
Include every association of the model ({ all: true }).
Default Value ​
falseas? ​
optionalas?:string
Defined in: src/associations/include.ts:48
Alias of the association, as given when it was defined.
association? ​
optionalassociation?:Association|string
Defined in: src/associations/include.ts:50
Association object or alias.
attributes? ​
optionalattributes?:FindAttributeOptions
Defined in: src/associations/include.ts:64
Selected attributes.
include? ​
optionalinclude?:IncludeOption
Defined in: src/associations/include.ts:66
Nested includes.
lateral? ​
optionallateral?:boolean
Defined in: src/associations/include.ts:80
postgrelize extensionFetch only the first limit rows per parent in the database (JOIN LATERAL over the parent keys) instead of loading every child and trimming in memory. Needs separate and limit. PostgreSQL extension.
Default Value ​
falselimit? ​
optionallimit?:number
Defined in: src/associations/include.ts:84
Maximum rows per include of a separate include.
model? ​
optionalmodel?:Model
Defined in: src/associations/include.ts:46
Associated model; the association is looked up by model (and as).
on? ​
optionalon?:unknown
Defined in: src/associations/include.ts:57
Custom ON condition of the join; replaces the condition derived from the association keys. Not used by belongsToMany includes (the junction joins keep their key conditions). See WhereOptions.
order? ​
optionalorder?:unknown
Defined in: src/associations/include.ts:82
Order of a separate include.
paranoid? ​
optionalparanoid?:boolean
Defined in: src/associations/include.ts:87
For paranoid targets: false includes soft-deleted rows.
Default Value ​
truerequired? ​
optionalrequired?:boolean
Defined in: src/associations/include.ts:59
INNER JOIN (true) or LEFT OUTER JOIN (false).
right? ​
optionalright?:boolean
Defined in: src/associations/include.ts:62
Use RIGHT OUTER JOIN.
Default Value ​
falseseparate? ​
optionalseparate?:boolean
Defined in: src/associations/include.ts:69
Load a hasMany association with a separate query instead of a JOIN.
Default Value ​
falsethrough? ​
optionalthrough?:IncludeThroughOptions
Defined in: src/associations/include.ts:71
Junction options for belongsToMany.
where? ​
optionalwhere?:unknown
Defined in: src/associations/include.ts:52
Filter on the included rows; makes the include required unless required: false. See WhereOptions.