Reputation: 1238
I am using sequelize.
const total = await models.parcel.findAndCountAll({ group: ['status'] });
And I got this response.
But I want to only count not rows on response.
How can I make this? Thank you so much for reading my question.
{
"count": [
{
"status": null,
"count": 8
},
{
"status": "1",
"count": 5
},
{
"status": "2",
"count": 3
}
],
"rows": [
{
"id": 3,
"companyName": "hy",
"invoice": "904103",
"receiverName": "Rtrt",
},......
]
}
Upvotes: 0
Views: 33
Reputation: 58553
Just Change findAndCountAll
to count
:
await models.parcel.findAndCountAll({ group: ['status'] });
To :
await models.parcel.count({ group: ['status'] });
Upvotes: 1