Let's say I have the following structure:
{
"-InSwU2yHOEHwhP_m4_n" : {
".priority" : 0.0,
"name" : "abc"
},
"-InSw_P0j8A-0Njj0Uvf" : {
".priority" : 1.0,
"name" : "def"
}
}
I would like to add another similar element with a directive as a key, and the priority is equal to the number of elements currently represented (in this case 2). The result should look something like this:
{
"-InSwU2yHOEHwhP_m4_n" : {
".priority" : 0.0,
"name" : "abc"
},
"-InSw_P0j8A-0Njj0Uvf" : {
".priority" : 1.0,
"name" : "def"
},
"-InSxV-RVkZ07_f3uDnJ" : {
".priority" : 2.0,
"name" : "ghi"
}
}
Please note: since several clients may try to add such an item at the same time, it must be a transaction.
Any ideas?
source
share