How Can Paginate On Mongodb With More Than 2 Field
My Data Looks like this {_id,product_name,price,rating,search_score}
To Paginate Next Page With 2 Sort Field (Price , _id) , I Am Using This Logic
db.users.find({
$or: [
{ price: { $gt: 99 } },
{
price: 99,
_id: { $gt: ObjectId("5f7f1f7d67f67ddaa622b796") }
}
]
}).sort({
price: 1,
_id: 1
}).limit(3).pretty()
So Now I Want To Sort More Than 2 Field That Is (Price,rating,_id) 3 Field Or Else 4 Field With (Price,rating,search_score,_id,) And I Have Compound Index For (Price,rating,_id) And Also For (Price,rating,search_score,_id,) But I Am Bit Confused In DB Query And I Would Be Thankful If You Can Help Me Out