Attempting to implement cursor based pagination – and I would like to know the proper way to call it with Knex
for Postgres
.
Here is the standard statement:
SELECT
FROM
WHERE (timestamp, id) > (cursor.age, cursor.id)
ORDER BY timestamp ASC, id ASC
LIMIT
And my attempt with Knex
:
const knexResult = await knex({ 'table_name' })
.select(columns)
.where('created_at', '>', cursor.timestamp)
.andWhere('id', '>', cursor.id)
.orderBy(['timestamp', 'id'])
.limit(first)
return knexResult;
Is this the proper way to call it – it seems not correct…