Reputation: 45
My requirement is to create a blood bank donors details. While clicking each blood group, it should take to new Activity where it shows the details of donors with that blood group (name, contact no, last donated). I have Created collection as "Blood bank" , and documents with name of each blood group. Under these documents I need to give details of donors(as shown in the picture). Which data type is to be used while adding the field data. Or is there any better way i can do this.
Upvotes: 0
Views: 76
Reputation: 1226
Yes, there is a better way to do this:
1st: Structure your db this way:
BloodBank (collection)
--- {DonorId} (document) [you can make firestore auto-assign the Donor Id)
--- blood_group (String)
--- ...(the other fields)
This way, things stay scalable.
2nd: In your app, upon a click on a particular blood group, you trigger a query to search for Donors with blood_group == (the blood group that has been clicked).
Loop through the donor documents and display the fields however you want in the app.
I would change the date field to a more low-level format timestamp (ISO String or Unix Time then convert in the app - this helps with sorting if you want to sort donors by donation date, later on).
Upvotes: 2