In cloud code I am using Data Service to put some game data for player, and then retrieve them for player
for example I am adding 3 items into player weapon inventory and retrieve his weapon inventory for player, each item has its own entry/ID for future query.
but not all new item is added before returning the inventory to player.
Player already has: Weapon A
Then I want to add Weapon B, C and D
In Cloud Code, here are steps:
This is because queries are eventually consistent, whilst acquiring items by id is immediately consistent as stated in our documentation.
Although the Game Data Service is immediately consistent for GetItems requests, it's eventually consistent for queries. This means that if you insert data into a Data Type and then immediately query it, you might not get the results you were expecting"
You should simply:
1) Add 3 new weapons to the document in cloud code.
2) Persist that document to the DB.
3) Return the document (or the subset of it containing the weapons data he wants) to the client.
You should just give each document the same ID as the player so you never need to query it, rather you can just acquire it by id.
Best regards, Patrick.
So, will it be better if I store a array of ID that player has in his private data set and retrieve the weapon from that array by finding it from DB?