Hi Ant,
You can achieve your objective with the Find Document By Query API, please have a look at the below API where you can get the count of the records which has matched to your query.
In the case of any concern please do feel free to reach out to us, we will be happy to help you.
Code snippet:
String dbName = "<Enter_the_dbName>";
String collectionName = "<Your_Collection_Name>";
String key1 = "name";
String value1 = "Nick";
String key2 = "age";
int value2 = 30;
Query q1 = QueryBuilder.Build(key1, value1, Operator.EQUALS); // Build query q1 for key1 equal to name and value1 equal to Nick
Query q2 = QueryBuilder.Build(key2, value2, Operator.GREATER_THAN); // Build query q2 for key2 equal to age and value2 equal to 30
Query query = QueryBuilder.CompoundOperator(q1, Operator.OR, q2);
// Pass aggregated query to finder method below. Similarly you can aggregate more conditions in querying object.
App42Log.SetDebug(true); //Print output in your editor console
App42API.Initialize("API_KEY","SECRET_KEY");
StorageService storageService = App42API.BuildStorageService();
storageService.FindDocumentsByQuery(dbName,collectionName,query, new UnityCallBack());
public class UnityCallBack : App42CallBack
{
public void OnSuccess(object response)
{
Storage storage = (Storage) response;
IList<Storage.JSONDocument> jsonDocList = storage.GetJsonDocList();
// following line of code use for getting size of json doucumemt
Int totalSize=jsonDocList.Count
for(int i=0;i <jsonDocList.Count;i++)
{
App42Log.Console("objectId is " + jsonDocList[i].GetDocId());
App42Log.Console("jsonDoc is " + jsonDocList[i].GetJsonDoc());
}
}
public void OnException(Exception e)
{
App42Log.Console("Exception : " + e);
}
}