0
votes

I am new to flutter as well as firebase and have structured my data as follows:

  {
      "a": {
        "b" : [ {
          "property1" : value1,
          "property2" : value2
           }, {
          "property1" : value3,
          "property2" : value4
          }]
       }
    }

Firebase database has numbered my array objects as 0,1

As you can see b contains array of objects, how do I create a query if I want to update a value in object which contains property2 value as value2 ? Do I have to modify my database structure?

1

1 Answers

2
votes

You won't be able to do this with a single update. You're going to have to:

  1. Query the children of a/b to find the child that contains value2. The name will be a string with the index of the child you found.
  2. With the name of that found child, perform an update of a/b/{child}.