Time reverse paging query, the page in the new data inserted into the DB, resulting in the return of duplicate data, there is no good solution? Thank you

Source: Internet
Author: User

Time reverse paging query, the page in the new data inserted into the DB, resulting in duplicate data, what is the best solution? Thank you

Reply content:

Time reverse paging query, the page in the new data inserted into the DB, resulting in duplicate data, what is the best solution? Thank you

What do you mean by repeating the data, in the process of page flipping, someone inserts a piece of data, and then the last piece of data on the first page is reassigned to the second page, which becomes the first output of the second page, and this data appears two times?
If this is the meaning, I suggest you paging in the client to do, when the query to add a point in time, less than the time of the Click Query button data will be detected, and then paging on the client, so that new data will not affect paging, because the new data is not taken back. Since this is a time flashback, even new data will not be seen and there will be no data omissions. When the data is loaded again, the data is picked up and the new data is queried.

The previous time has just dealt with the mobile side of similar problems, the mobile side of the idea:
1, the first is divided into pull down (get the latest data) and slide up (get previous data)
2, and then each time I swipe up to get the previous data, I pass an ID, which is the condition to get the data. You are the time in reverse, that the basic can be identified ID is also reverse, just pass the ID should be the smallest ID in the previous acquisition data, in addition to the first time, each subsequent acquisition of data is less than this ID data
3, the first time to obtain data, because there is no ID, so in order to obtain the first data can be.

Hope to help you with your problem!

Sorry to be the best language in the world.
And my answer is based on Nodejs.
But it does not affect, understand the idea is good.

-------Original Answer------

When I looked at Coding.net's API, I found that he had two more ways of doing it.
Syntax based on Mongoose
One is through pagination, pagify. For example, a page 20, model.find (query). Skip (page*20-20). Limit (20).
The second is to use the load more, specifically, after. I have not developed such a, unsure MongoDB has no after such properties. But depending on what is in a sort, it is relatively simple, model.find (query). Sort ('-time '). Where ({time:{$gt: Time}}). Limit (20)

Not sure there's no

If MongoDB had something like after, it would be better. (Note time may crash, and ID will not)
Model.find (query). Sort ('-time '). After ({id:id}). Limit (20)

Add more request API to Coding.net

GET https://coding.net/api/activities/projects_last?last_id=14959187

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.