I cannot find a standard way to paginate my update in Cassandra using the Node connector. I cannot find any resource that would explain how to do it or whether it is possible at all.
My function looks like this:
async function whitelistCustomers(account, customerIds) {
let data = [account._id.toString(), customerIds]
let options = { prepare: true, fetchSize: 200 }
let query = "UPDATE customers SET reason_blacklist=null WHERE id_account = ? AND id IN ?"
await new Promise((resolve, reject) => {
function rowCallback(n, rows) {}
function callback(err, result) {
if (err) reject(err)
else resolve()
}
client.eachRow(query, data, options, rowCallback, callback)
})
}
But it does not seem to work. When there are lots of customerIds
, the query fails with PayloadTooLargeError: too many parameters
.
I could solve this by making a custom JS pagination. I would iterate over customerIds
and make multiple queries to Cassandra with small portions of customerIds
each, but if I could find a more standard way to do this it would be best.
do {
let paginatedCustomerIds = customerIds.splice(0, 200)
// make a request with paginatedCustomerIds
} while (customerIds.length > 0)
Is it possible to paginate the update request? If yes how do I do it?