Skip to content

SORT & Pagination

const users = await pulsabase.from(User)
.sort('created_at', 'desc')
.sort('name', 'asc')
.find();
// Page 3 of 20 results per page
const page3 = await pulsabase.from(User)
.sort('created_at', 'desc')
.limit(20)
.offset(40)
.find();

For better performance on large datasets:

// First page
const page1 = await pulsabase.from(User)
.sort('id', 'asc')
.limit(20)
.find();
// Next page — use last item's ID
const lastId = page1[page1.length - 1].id;
const page2 = await pulsabase.from(User)
.where('id', { $gt: lastId })
.sort('id', 'asc')
.limit(20)
.find();