I get all the games from a firebase collection. This gamescollection is looking like following:
{
zgaHRO2yW6lafg1ubz4y : { // This is a game
createdOn: Timestamp,
finished: false,
game: "TNhII8jDU23GUZyyqH5X",
players: {
NJ2U5MwVAIww6TWkHMv2: true,
lfNFlKnsbuUJGwINcJ4RMXbNVfs1: true
},
startedBy: "lfNFlKnsbuUJGwINcJ4RMXbNVfs1"
},
QSkjMQS1232ezklmqKSDJoi : { // This is a game
createdOn: Timestamp,
finished: false,
game: "TNhII8jDU23GUZyyqH5X",
players: {
AQSDNJ2U5MwVAIwWkHMv2: true,
lfNFlKnsbuUJGwINcJ4RMXbNVfs1: true
},
startedBy: "lfNFlKnsbuUJGwINcJ4RMXbNVfs1"
}
}
To get all the games, I perform the following action:
const gamesCollection = db.collection('games')
firebase.gamesCollection.where('finished', '==', false).orderBy('createdOn', 'desc').onSnapshot(querySnapshot => {
querySnapshot.forEach(doc => {
const games = doc.data()
})
})
This works nice: I get all the games that are not finished yet... But now I want to "query" them like such:
- Get all the games where player
lfNFlKnsbuUJGwINcJ4RMXbNVfs1
is involved. - Get all the games where player
lfNFlKnsbuUJGwINcJ4RMXbNVfs1
OR playerNJ2U5MwVAIww6TWkHMv2
is involed
Can't seem to figure out how it's done...