-
Notifications
You must be signed in to change notification settings - Fork 0
Firebase database operations
Pombo edited this page May 11, 2016
·
3 revisions
The application data is contained in three main nodes: players, games and tables.
{
"players": {},
"games": {},
"tables": {}
}Players data is added to the players root node. The new player is choosen by the player.
{
"players": {
"eritru": {
"name": "Eric Truong"
}
},
...
}Games data is added to the games root node. The new game ID is generated by Firebase.
{
"games": {
"-AAid321": {
"name": "Tarot",
"minPlayers": 4,
"maxPlayers": 5
}
},
...
}Tables data is added to the tables root node. The new game ID is generated by Firebase.
As there is a two-way relationship between a table and a game, a table cannot be created if the games node is empty.
One table can only reference one game. A table holds its game ID in the game field.
One game can reference many tables.
{
"games": {
"-AAid741": {
"name": "Uno",
...
"tables": {
"-GGid456": true
}
},
...
},
"tables": {
"-GGid123": {
"game": "-AAid321",
"startTime": 1462531800,
"players": {}
}
},
...
}A player may join a table of his choosing.
One table can reference many players.
One player can reference many games.
{
"players": {
"eritru": {
"name": "Eric Truong",
"tables": {
"-GGid456": true
}
},
"khazen": {
"name": "Khalil Zendah",
"tables": {
"-GGid456": true
}
},
...
},
"tables": {
"-GGid456": {
"game": "-AAid741",
...
"players": {
"eritru": true,
"khazen": true
}
}
},
...
}{
"players": {
"eritru": {
"name": "Eric Truong",
"tables": {
"-GGid456": true
}
},
"khazen": {
"name": "Khalil Zendah",
"tables": {
"-GGid456": true
}
},
"henake": {
"name": "Henrik Akesson",
"tables": {}
}
},
"games": {
"-AAid321": {
"name": "Tarot",
"minPlayers": 4,
"maxPlayers": 5,
"tables": {
"-GGid123": true
}
},
"-AAid741": {
"name": "Uno",
"minPlayers": 2,
"maxPlayers": 10,
"tables": {
"-GGid456": true
}
},
"-AAid258": {
"name": "Monopoly",
"minPlayers": 2,
"maxPlayers": 6,
"tables": {}
}
},
"tables": {
"-GGid123": {
"game": "-AAid321",
"startTime": 1462531800,
"players": {}
},
"-GGid456": {
"game": "-AAid741",
"startTime": 1462532400,
"players": {
"eritru": true,
"khazen": true
}
}
}
}