'Sequelize v5 findAndCountAll Include Columns
When using findAndCountAll sequelize runs two queries. The first does the count but it doesn't include any of the attribute fields. Is there any way to make the count query include the attribute fields?
Solution 1:[1]
There is no need to include attributes in count query because it's used for counting the total number of records that satisfy all indicated conditions and count query doesn't use limit and offset parameters for that same reason unlike SELECT query to get limited number of records with all indicated attributes.
If you have 100 records that meet all conditions and you also indicated limit: 10 and offset:20 then you will get 10 records starting from offset 20 and count will be equal to 100. This will allow you to determine how many pages of records you can get.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Anatoly |
