Serious Issue Regarding Cloud Storage

0 votes
We are integrating the cloud APIs and we want to store the following player data in the cloud:
 
  • No of power ups available
  • Player Level
  • Player XP
  • Win, Losses Draws etc
 
We tried using Shephertz's storage api. We were successful in saving the data to database and collections but we are having problems regarding querying the data back.
 
Each document has a document ID which can be used to query data but the document IDs are returned in the form of a list. How can we query a particular doc ID for a particular document?
 
For example I have multiple documents for level, XP, power up and I want to query the power up data. I will get a list of doc IDs in the callback function when I save the data. Now how do I know which docid is for power up data?

 

asked Oct 13, 2015 in App42 Cloud API-BaaS by lucidlabs (10 points)

1 Answer

0 votes

Hello Developer,

 

If we understood your query correclty, than you are saving some keys value (like "powerup":100) to save your power ups in Storage service right. If you are doing in the same way than you can find it easily using FIndDocumentByKeyValue or use FindDocumentByQuery method in which you can find your document based on muliple statement. Please have a look into above links and let me know if you need any help from my side. 

Regards,

Himanshu Sharma

answered Oct 14, 2015 by hs00105 (2,005 points)
But we cant always know how many powerups were there last stored for each user
Hello Jibran,

Apologies for the delay in response.

You can get the based on user name or the owner which is going to store the information in Storage service, In order to find the document based on owner name, you just need to set the logged in user before calling insert api of Storage service.

App42API.setLoggedInUser("Name of user");  

Once you integrate the above code snippet, your document saved with owner name which is logged in the App. To find the document based on owner name, you can use below code snippet and let me know if it helps:

String dbName = "<Enter_the_dbName>";  
String collectionName = "<Your_Collection_Name>";   
String key = "_$owner.owner";   
String value = "Nick";
int max = 5;    
int offset = 0;    
Query q1 = QueryBuilder.build(key, value, Operator.EQUALS); // Build query     
// Pass aggregated query to finder method below. Similarly you can aggregate more conditions in querying object.   
App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");
StorageService storageService = App42API.buildStorageService();
storageService.findDocumentsByQueryWithPaging(dbName, collectionName, q1, max, offset, new App42CallBack() {
public void onSuccess(Object response)
{
    Storage  storage  = (Storage )response;
    System.out.println("dbName is " + storage.getDbName());
    System.out.println("collection Name is " + storage.getCollectionName());
    ArrayList<Storage.JSONDocument> jsonDocList = storage.getJsonDocList();            
    for(int i=0;i<jsonDocList.size();i++)
    {
        System.out.println("objectId is " + jsonDocList.get(i).getDocId());  
        System.out.println("CreatedAt is " + jsonDocList.get(i).getCreatedAt());  
        System.out.println("UpdatedAtis " + jsonDocList.get(i).getUpdatedAt());  
        System.out.println("Jsondoc is " + jsonDocList.get(i).getJsonDoc());  
    }
}
public void onException(Exception ex)
{
    System.out.println("Exception Message"+ex.getMessage());   
}
});   

Let me know if you still face any issue or need further help, please share your Skype id, will connect over Skype and resolve this ASAP.


Regards,
Himanshu Sharma
App42 team
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
...