Reputation: 23
I have a table which have 4750 rows, however, when I use findAndCountAll() it always returns 1000 rows even I set limit with 2200 rows. I'm using Sequelize with a Oracle DB.
There is a configuration to allow me return whole 4750 rows with only 1 request?
Request GET in my API
const { count, rows } = await User.findAndCountAll({
offset: 1,
raw: true,
limit: 2200,
subQuery:false
});
response JSON I get from findAndCountAll
{
"count": 4750,
"rows": [
{
"id": "10003734",
"name": "LUIS"
},
{
"id": "10003735",
"name": "PEDRO"
},
{
"id": "10003736",
"name": "CARLOS"
}}
....997 rows more
]
}
Upvotes: 2
Views: 763
Reputation: 51
In sequelize, the maxRows option default to 1000 unless it is set. You can get the sequelize instance that would return more than 1000 rows by setting the maxRows option when getting a Sequelize instance.
You can get the Sequelize instance as I have shown below and then do the findAndCountAll call.
const sequelize = new Sequelize(dbConfig.serviceName, dbConfig.user,
dbConfig.password,{host: dbConfig.host, port:
dbConfig.port, dialect: 'oracle', dialectOptions: {maxRows: 2500}});
Upvotes: 1