Skip to main content
Answer

Pagination and returning records at a specific page

  • July 27, 2023
  • 2 replies
  • 94 views

Hello data modeling team, I tried the "first" and "after" filter on Query Explorer which enables us to retrieve the query result page by page, it works well.

while we have an existing API which enables the consumer to specify an "offset" and a "limit" parameter. by the offset, the consumer could retrieve records at any specific page without the need to always go though from the beginning and then retrieve page by page, it's like the skip and limit syntax in mongodb, for example, db.myCollection.find().skip(200000).limit(50).

we want to keep the API behavior so no modification needed for existing consumer, while we do not want to simulate the offset behavior by retrieving page by page within our own API since it will be very low efficient when there is a big dataset, so is it possible to provide the offset supporting in Cognite ? or any suggestions/methods we could try to implement this ? Thanks!

 

Best answer by Jason Dressel

@Lihui Meng,
Today, getting a list of pages or navigating by offset is not supported.  This was a conscious decision.  In short, records may change (added or deleted) by other users or processes while any given user is navigating the records.  Navigating to a particular offset may return different records each time the request is made.
 

A similar request was asked: 

-Jason

2 replies

  • Author
  • Committed
  • July 27, 2023

add a image for the question

 


Forum|alt.badge.img
  • Seasoned Practitioner
  • Answer
  • July 27, 2023

@Lihui Meng,
Today, getting a list of pages or navigating by offset is not supported.  This was a conscious decision.  In short, records may change (added or deleted) by other users or processes while any given user is navigating the records.  Navigating to a particular offset may return different records each time the request is made.
 

A similar request was asked: 

-Jason