Due to the limit of retrieving 100 times on GameDataService, in order to retrieve more, please try the following method using pagination:
- Sort the data using Spark.getGameDataService().sort() // For example sort by id
- Perform your initial query on the database.
- Store all the returned documents into an array. // This will be your list for all your items
- After the query is completed, that is 100 documents have returned, check to see if the array's length is divisible by 100, that is: array.length % 100 == 0 // This means that there can be more documents to be returned.
- Create a new query that is greater than the last index of the array sorted field. // For example, if you are sorting by id and the last index id is 100, then the query will be retrieving all id's between 101 and 200.
After this, the array you populated with your documents will be the list of all the items stored from your database. It is recommend, depending on your requirements, to put a hard limit on the number of documents recalled at any given time because thousands of documents could cause the request to time out.
Important: This approach will only work if the field being queried/sorted on is unique.
Bellow is an example code snippet of how it should look: