I want to remove multiple elements from my Firestore array:
var eliminatedThisRound = []
for (const player in players){
if (players[player].eliminated === false && players[player].answer !== answer) {
eliminatedThisRound.push(players[player].uid);
}
}
var update = {
roundFinished: true,
nextRound: date.valueOf() + 12000,seconds
players: updatedPlayers,
remainingPlayers: admin.firestore.FieldValue.arrayRemove(eliminatedThisRound)
}
await t.update(gameRef, update);
The above returns this error:
transaction failure: Error: Element at index 0 is not a valid array element. Nested arrays are not supported.
So it would be fine if I knew the values, as I could do something like this:
remainingPlayers: admin.firestore.FieldValue.arrayRemove("player1", "player2")
However I haven't found a way to make the parameter of arrayRemove() dynamic.
Any idea?
arrayRemove: firebase.google.com/docs/reference/js/… and firebase.google.com/docs/reference/js/…. What happens when you pass multiple values? Is there an error message?eliminatedThisRoundin my code above) - however it returned this error:Element at index 0 is not a valid array element. Nested arrays are not supported.