Set up 36 practice orders
Run this once in mongosh against a development instance with an empty practice collection. It creates 31 paid orders and five cancelled orders. The same data works for the stable pagination guide.
const lab = db.getSiblingDB("keplergrid_query_lab")
lab.orders.insertMany(Array.from({ length: 36 }, (_, index) => {
const number = index + 1
const minute = Math.floor((number + 3) / 8)
return {
_id: "ORD-" + String(number).padStart(3, "0"),
status: number <= 31 ? "paid" : "cancelled",
created_at: new Date(Date.UTC(2026, 10, 1, 12, minute))
}
}))
Get the exact filter count
- Connect in Read only mode and open
keplergrid_query_lab.ordersin Documents. Paste this object into Filter.
{ "status": "paid" }
- Open Sort & projection and paste the following object into Sort. Click Run and set Rows to
25in the footer.
{ "created_at": -1, "_id": -1 }
- Click Count documents in the footer. It shows 31 matches, even though the result page holds 25 documents.
The count applies the server-side filter across the collection. Sorting, projection and page size leave that count unchanged. Use Count again to refresh the number after another client changes the data.
Compare a page search with a filter
- On the first page, enter
ORD-006in Find in results. The grid finds no matching loaded row, and the count still shows 31 matches. The order is just beyond the first 25 rows. - Clear Find in results. Replace Filter with the query below, then click Run and Count documents.
{ "status": "paid", "_id": "ORD-006" }
MongoDB returns ORD-006 and the footer shows 1 match. On a large dataset, narrow the server filter if a count takes too long.
Next, try paging through these same orders with a stable sort or see more MongoDB query filters.
Next, Find distinct MongoDB values and count their documents.