Sign In Register

How can we help you today?

Start a new topic

Data Service backcall?

Hi,


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. 


for example:


Player already has: Weapon A


Then I want to add Weapon B, C and D


In Cloud Code, here are steps:


  1. Add three new weapons for player
  2. Query weapons that player has
  3. Return the result to player

What I found the result only has Weapon A only. What I need is a callback function which when all 3 Weapons is all added to DataService, then I can query those for player and return result.

Derek


Hi Derek, 


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?

Login to post a comment