Trying to understand "FindDocumentsByQueryWithPaging"

0 votes

Hi,

So I recently realised that a normal FindDocumentsByQuery call limits the amount of results to 100 so I am trying to work out a way to get all the documents that match a particular query.

I am currently trying to use FindDocumentsByQueryWithPaging and have run into a few things that I've noticed...

1) Whatever value I set for the "max" param is of course how many documents I receive however storage.GetRecordCount() will return the same value (unless there are fewer records. If I have 150 records and "max" is set to 100, storage.GetRecordCount() tells me there are 100 records. How do I get it to tell me if there are more records that have not been loaded?

2) How would I then go about loading the next page of records? I have attempted to call FindDocumentsByQueryWithPaging() within the callback of the first - using exactly the same params except incrementing the offset by jsonDocList.Count. It seems like this should work but I get the following error when I try (not that the line number #1628 corresponds to where I attempt to call FindDocumentsByQueryWithPaging() within the CallBack:

 

system.NullReferenceException: Object reference not set to an instance of an object

  at SessionSupervisor+PagedScoreUpdateCallBack.OnSuccess (System.Object response) [0x00480] in /Users/Anthony/SourceTree Repos/Unity/LootSpace/Assets/LootAssets/Scripts/User Data/SessionSupervisor.cs:1628 
  at com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorWWW.BuildResponseForObjectService (System.String successValue, App42CallBack callBacK, System.String resource) [0x00000] in <filename unknown>:0 
  at com.shephertz.app42.paas.sdk.csharp.connection.RESTConnectorWWW+<Execute>d__6.MoveNext () [0x00000] in <filename unknown>:0 

UnityEngine.Debug:LogError(Object)

asked Mar 24, 2019 in Unity by ant (13 points)
I had seen another post that told me not to use GetCountByQuery() as it was going to be depreciated so I have avoided using this as an alternative.
I realised I was using storage.GetRecordCount() instead of storage.GetTotalRecords(). But storage.GetTotalRecords() returns -1 regardless of how many records have already been retrieved.

1 Answer

+1 vote

Hello Ant,

Greetings from ShepHertz!!!

You can use Find Document By Query With Paging API of the storage Service, where you find the document using the custom query with paging.

In the case, if you have 150 records and you have to fetch all those records using this API, you can set the offset 0 and max 99 to fetch the first 100 records and after again set the offset 100 and max 149 to fetch another 50 records, repeat the process until you get fetch all the records.

If you have any other concern please let us know, we will be happy to help you.

Regards,

Priyanka Singh

App42 Team

 

answered Mar 25, 2019 by anonymous
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...