addOrUpdateKeys question

0 votes
Hello world! Suppose i have this json stored is database. { "array" : [ 1, 2 ] } Then, two clients run cloud code and try to update this array like this. Client_1 -> [ 3, 4 ] Client_2 -> [ 5, 6 ] If they both call addOrUpdateKeys on this array i will get [ 1, 2, 3, 4, 5, 6 ] ( the elements order doesn't matter ). Or we will get situation when ( suppose ) Client_1 override array with values [ 3, 4 ] and then Client_2 override array to, and as result we will get [ 5, 6 ] ?

------------------------

Is there any api to remove or add element to jsonarray without touching another elements in array?

And can we remove value by key without retrieving JSONObject first?
asked Mar 29, 2016 in Cocos2D-X by Kirill Kotov (39 points)
edited Mar 29, 2016 by Kirill Kotov

1 Answer

0 votes
 
Best answer

Hi Kirill,

Updating an element in JSONArray like which you shown in the example is not available. Using  the addOrUpdateKeys method will update the whole value of key "array" in case you send [5,6] from the request. In order to do this, you need to call the fetch method first to update the document. Using the fetch method, you have the JSONArray in which you can append new values and update it to the document.

Let me know if it helps.

 

Regards,

Himanshu Sharma

answered Mar 30, 2016 by hs00105 (2,005 points)
selected Mar 30, 2016 by Kirill Kotov
Thanks. Ihave another question.
Can i retrieve all sended friend requests? ( BuddyService )
And where i can see all buddy requests with usernames and messages?
Can i cancel my friend request?
If i add to ban list user who sent me fried request. This request will be automaticaly removed?
Hi Kirill,

Please find my answer inline for your query:

Can i retrieve all sended friend requests?

Ans:  As of now, it's not possible. However if it is required then you can maintain it easily in the storage service(
http://api.shephertz.com/app42-docs/nosql-storage-service/) with repect to user. Let me know in case you need any help while integrating this.

Where i can see all buddy requests with usernames and messages?

Ans: You can fetch users message/request using the API. Please have a look at this(http://api.shephertz.com/app42-docs/buddy-management-service/) link for more details.  

Can i cancel my friend request?

Ans: Yes, you can. Click here(http://api.shephertz.com/app42-docs/buddy-management-service/#reject-friend-request) for code snippet.

If i add to ban list user who sent me fried request. This request will be automaticaly removed?

Ans: Yes, if you block any users then the request will automatically removed.

Let me know if you have any other  question, I will be happy to help you!!

Regards,

Himanshu Sharma
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
...