Not all jsons are sent to the cloud when I call InsertJSONDocument

0 votes

That's how I'm inserting the objects, and it's sending them to the cloud but only some of them show up. When I test it multiple times sometimes only 2 objects are stored, sometimes 3. Never all 4 and not sure why.
asked Mar 12, 2014 in App42 Cloud API-BaaS by JoeCrill (25 points)

1 Answer

0 votes

In your script, you might be fetching data from InsertJSONDocument callback this will always return one document which is inserted by you in that function. Please use "FindAllDocuments "    to get all doc List from your given collection.

answered Mar 12, 2014 by sshukla480 (407 points)
Well if the insertJSONDocument isn't inserting all the documents into the collection how am I suppose to use the FindAllDocuments if they're not all being put into the collection?
so your objects are not showing in AppHQ  console or try to count your objects in your callback.
Ok now the objects are showing up in the AppHQ console but I'm pretty sure the code isn't working how it should be. In the second part of the code I'm trying to assign the object id to a playerpref variable but I don't think it goes in order so it's messing it up. How can I work around that?
If you are using same callback for insert and find so please separate your callbacks in your script. And change your code like this.
Storage storageObj = (Storage)response ;
IList<Storage.JSONDocument> jsonDocList = storageObj.GetJsonDocList();
PlayerPrefs.SetString("MoneyID", jsonDocList[0].GetDocId());
Well since I'm trying to insert multiple json docs the callback jsonDocList has multiple values but when I iterate through them the order seems to be different every time which is my problem. How can I prevent that? Or do I need a seperate callback script for each time I insert a json doc? See how I'm trying to insert multiple json docs and keep track of all the object ids -

but the problem is it seems the object ids get assigned randomly each time the code is ran and there's not an order.
If you are inserting multiple JSON docs in same time, so you have to create a different callback for each InsertJSONDocument.
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