Firebase - rename a node?

All,
I’m working on my grocery list app (yes, the one that could have been last week’s WDC submission). I have a firebase data structure like:

User/Lists/List_name/Meal_name/Peaches/sku: 01234
                                      /quantity: 2
                             /Beans   /sku: 54321
                                      /quantity: 1

My problem is that I’d like to let users change the name of an ingredient (i.e. Peaches to Ripe Peaches). I can’t for the life of me figure out how to do that with Firebase, except to copy everything under the Peaches node to Ripe Peaches and then delete the Peaches node.

Is there a better way?

3 Likes

Not of what I know.

The other way of course is a slight change in the structure and instead of having a node as an ingredient name have the node be “Ingredient” and under this node is the details with the ingredient name included.

User/Lists/List_name/Meal_name/Ingredient
                                      {Name: Peaches,
                                      sku: 01234,
                                      quantity: 2}

                                     {Name: Beans,
                                     sku: 54321,
                                     quantity: 1}

This way the ingredients are merely a list of objects under the node “Ingredient” which you can manipulates

1 Like