0

So i have this Transaction database where i store the UID of Client, Worker, and PushID of the job, and when the worker take a job, worker supposed to get data about client Name from ClientID along with every data stored inside the JobID, while Client get data about Worker name from WorkerID along with every data in the same JobID, how do i achieve this ?

{
  "Transaction" : {
    "-M9yM-F8F6pPJEqSVFhm" : {
      "ClientID" : "rFKXOXIp2HQWbLGBjSENdzGq4lq2",
      "JobID" : "-M9tDcM4NHpZCzCftxo4",
      "WorkerID" : "HFaZtI241mfziA6pkHycw2DTOYh2"
    }
  },
  "description" : {
    "-M9tDcM4NHpZCzCftxo4" : {
      "Address" : "123asdasda",
      "ClientID" : "rFKXOXIp2HQWbLGBjSENdzGq4lq2",
      "JobID" : "-M9tDcM4NHpZCzCftxo4",
      "RoomSize" : "Large (luas diatas 16M)",
      "Service1" : "Cleaning",
      "Service2" : "Room Organizing",
      "Service3" : "Bathroom Cleaning",
      "Service4" : "Organizing Laundry",
      "eHour" : "12",
      "eMin" : "00",
      "sHour" : "11",
      "sMin" : "00"
    }
  },
  "userdesc" : {
    "HFaZtI241mfziA6pkHycw2DTOYh2" : {
      "email" : "testing123@gmail.com",
      "id" : "2545878096555",
      "name" : "Test123",
      "pass" : "blablabla",
      "phone" : "08000000000"
    },
    "rFKXOXIp2HQWbLGBjSENdzGq4lq2" : {
      "email" : "eaglejason13@gmail.com",
      "id" : "125565896587452",
      "name" : "Jason Chrislie",
      "pass" : "123456789",
      "phone" : "087883592045"
    }
  }
}
  • With your current data structure you'll need to do a client-side join for this. See https://stackoverflow.com/questions/46184206/fetching-details-of-a-group-user-belongs-to-in-firebase. As also explained there, the alternative is to duplicate the necessary user data under each transaction. Either of these can be an acceptable solution, and neither of them is pertinently better than the other. – Frank van Puffelen Jun 16 '20 at 20:45
  • @FrankvanPuffelen can i search the transaction that contains my current user uid and trace the data afterwards since worker uid and client uid are always the same as current user uid, if yes how ? – Jason Chrislie Jun 16 '20 at 21:04
  • Sounds feasible. Where are you stuck? It will be a lot easier to help you if we can see the code of what you tried, and where you ran into problems. – Frank van Puffelen Jun 16 '20 at 23:06
  • @FrankvanPuffelen actually i manage to solve my problem, thank you for the help sir – Jason Chrislie Jun 19 '20 at 20:45

0 Answers0