* If you want to set several target instances, but with different attributes you have to set the attributes on the instance, using a property with the name of the through model:
* If you want to set several target instances, but with different attributes you have to set the attributes on the instance, using a property with the name of the through model:
...
@@ -46,10 +45,10 @@ const Op = require('../operators');
...
@@ -46,10 +45,10 @@ const Op = require('../operators');
*
*
* Similarly, when fetching through a join table with custom attributes, these attributes will be available as an object with the name of the through model.
* Similarly, when fetching through a join table with custom attributes, these attributes will be available as an object with the name of the through model.
* ```js
* ```js
* user.getProjects().then(projects => {
* const projects = await user.getProjects();
* let p1 = projects[0]
* const p1 = projects[0];
* p1.UserProjects.started // Is this project started yet?
* p1.UserProjects.started // Is this project started yet?
* })
* })
* ```
* ```
*
*
* In the API reference below, add the name of the association to the method, e.g. for `User.belongsToMany(Project)` the getter will be `user.getProjects()`.
* In the API reference below, add the name of the association to the method, e.g. for `User.belongsToMany(Project)` the getter will be `user.getProjects()`.
* Find all the rows matching your query, within a specified offset / limit, and get the total number of rows matching your query. This is very useful for paging
* Find all the rows matching your query, within a specified offset / limit, and get the total number of rows matching your query. This is very useful for paging
*
*
* @example
* @example
* Model.findAndCountAll({
* const result = await Model.findAndCountAll({
* where: ...,
* where: ...,
* limit: 12,
* limit: 12,
* offset: 12
* offset: 12
* }).then(result => {
* });
* ...
* })
*
*
* # In the above example, `result.rows` will contain rows 13 through 24, while `result.count` will return the total number of rows that matched your query.
* # In the above example, `result.rows` will contain rows 13 through 24, while `result.count` will return the total number of rows that matched your query.
* If you are running a type of query where you don't need the metadata, for example a `SELECT` query, you can pass in a query type to make sequelize format the results:
* If you are running a type of query where you don't need the metadata, for example a `SELECT` query, you can pass in a query type to make sequelize format the results:
* If you have [CLS](https://github.com/Jeff-Lewis/cls-hooked) enabled, the transaction will automatically be passed to any query that runs within the callback
* If you have [CLS](https://github.com/Jeff-Lewis/cls-hooked) enabled, the transaction will automatically be passed to any query that runs within the callback