Updating a string in multiple locations in firebase -


i'm making app database structure this:

{     "locations": {       "location1": {         "name": "nice location"       }     },      "user_posts": {       "user1": {          "post1": {          "location_name": "nice location",          "location_id": "location1",          "description": "wow!"         },          "post2": {          "location_name": "nice location",          "location_id": "location1",          "description": "nice"         }     } } 

if have change location1 name, how change location_name's users posts have? have download data before , update or there other method?

i think using location id location name every location when user enters posts not idea.

you can add 1 more attribute location1 , islocationof , store user id or perhaps post id/post names.

"locations": {   "location1": {     "name": "nice location",     "islocationof": {                'post1': true,                'post2': true                      }   } } 

here islocationof attribute of locations value object.
now if locations1's name gets changed can retrieve islocationof object , iterate through , posts id/name containing location.then use post ids update entries having address .
       also whenever add new post , have add post id/name islocation object.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -