如何将MongoDB ObjectId作为上一个和下一个按钮的键进行分页?

时间:2023-01-27 16:29:20

I have pagination in my page with Previous and Next button.

我在页面中使用“上一个”和“下一个”按钮进行分页。

If i click Next button, i am using following method,

如果我单击下一步按钮,我使用以下方法,

db.test.find({'_id': {'$gt': '10th _id'}}).limit(10)

but don't know which method need to use when am clicking Previous Button also need to hide the Previous button in staring page and need to hide the Next button when i am in last page.

但是当我点击上一个按钮时还不知道需要使用哪种方法也需要在盯着页面中隐藏上一个按钮,当我在最后一页时需要隐藏下一个按钮。

Please help me to solve the issue.

请帮我解决这个问题。

Thanks.

谢谢。

1 个解决方案

#1


0  

Store the current step in a variable and use skip(10) in MongoDB

将当前步骤存储在变量中,并在MongoDB中使用skip(10)

db.test.find({'_id': {'$gt': '10th _id'}}).skip(variableName).limit(10)

For hiding the previous and next buttons you will have to check separately. The variable name will help you with that.

要隐藏上一个和下一个按钮,您必须单独检查。变量名称将帮助您。

#1


0  

Store the current step in a variable and use skip(10) in MongoDB

将当前步骤存储在变量中,并在MongoDB中使用skip(10)

db.test.find({'_id': {'$gt': '10th _id'}}).skip(variableName).limit(10)

For hiding the previous and next buttons you will have to check separately. The variable name will help you with that.

要隐藏上一个和下一个按钮,您必须单独检查。变量名称将帮助您。