Sign In Register

How can we help you today?

Start a new topic

GameDataService: Atomic Update across Data Types

Hi,


I read that SparkDataItem.persistor().persist() only persisted data of a single data type, and one of my key concerns is how we could atomically persist data changes of different data types.


For example if I define 2 data types in my game: "currency" and "inventory". And I would like to do an atomic operation to decrease currency amount and increase the number inventory items at the same time - if one persistor fails for whatever, the other should not go through as well. Is there a way to achieve this?


Thanks,

Iris


2 people have this question
1 Comment

bump.


I also have this same problem.


In the MongoDB world, I would do this:


playerCards.update ( {playerId : playerid , "cards":{"$elemMatch":{ "id" : cardid, "count" : { "$gt" : 0 } }}},

                   {$inc : {"dust" : credits,"cards.$.count": -1} } , 

                    false, 

                    true);

                    


Here, I am adding "dust" and removing the count of cards, to implement a "dust" feature like in Hearthstone.

The same problem as removing currency and adding to inventory in an atomic operation.

This is a very common feature in video games. Why can't GameSparks help us and explain how to do this using this new GameDataService?


Otherwise we will be forced to continue using Mongo. I don't see the advantage at all to using the new GameDataService.


Thanks for any help.


Login to post a comment