Sign In Register

How can we help you today?

Start a new topic

Storing complex data in Runtime Collection

Hi there


I am new to gamesparks abut i am trying to learn fast so that i can complete the online components of my game fast.

The thing i want to do is to create ~10 runtime collections for countries which stores the list of cities, name, active players,best players. The no of cities is around 20/country.


Each city stores the list of active players ,players visited the city etc.


So whenever the player click on the country icon, its id is entered into the country collection's active player list, same with the country.


Basically players are able to add their entries in city as well as country.

What is the best way to do this kind of behavior and i want to know whether creating a single runtime collection for all countries will be better than individual collections or not?? 




 



Hi Himanshu,


You can set this up in whatever way makes you feel most comfortable to work with, 10 runtime collections for countries isn't an awful lot. If you did that you could have each city as a single document within each country collection. If you had a single country collection you would have each country stored as a single document and the cities stored as objects within these documents. With the second option you would have to search for an object within a document whereas with the first method you would only have to find the document in the collection. If you have a sample of the data you are looking to store we can make some suggestions on how to do it.


Thanks,

Liam

Sample data: 

   

  

{
    "name": "cityA",
    "population": 340000,
    "slavePopulation": 23000,
    "leftPopulation": 21000,
    "activeplayers": [
        {
            "name": "player1",
            "playerid": "2dd232dsdsds323233",
            "peoplecount": 23232,
            "healthy": 232,
            "infected": 333,
            "kills": 21,
            "converted": 22
        },
        {
            "name": "player2",
            "playerid": "2323232dgggggs223",
            "peoplecount": 23232,
            "healthy": 232,
            "infected": 333,
            "kills": 21,
            "converted": 22
        },
        {
            "name": "player3",
            "playerid": "232323dfsdf324fdf3",
            "peoplecount": 23232,
            "healthy": 232,
            "infected": 333,
            "kills": 21,
            "converted": 22
        },
        {
            "name": "player-n",
            "playerid": "232323dfsdf324fdf3",
            "peoplecount": 23232,
            "healthy": 232,
            "infected": 333,
            "kills": 21,
            "converted": 22
        }
    ],
    "players": [
        {
            "name": "Himanshu",
            "playerid": "2323233",
            "peoplecount": 23232,
            "healthy": 232,
            "infected": 333,
            "kills": 21,
            "converted": 22
        },
        {
            "name": "John",
            "playerid": "232233",
            "peoplecount": 2232,
            "healthy": 2322,
            "infected": 3333,
            "kills": 21,
            "converted": 22
        }
    ]
}

   The number of country will be 10 but may increase with time, so the solution should be scalable. A single country could contain upto 40 cities as more cities are  added later on.  The data in a single city document will be updated as player enter the city and leaves.A single city may contain upto 100 active players at a time. These players will update the data in their fields as they do attacks etc. The data in the fields of other players will also be updated on attacks. So a lot of updating will be done as the game progresses. What will be the best solution to store this data?

Login to post a comment