Edgar J.
Edgar J.

Reputation: 172

Firestore Sharing data with other users

I'm creating a travel app in flutter for people to create trips and share with other users that can modify its contents. I'm currently using firebase authentication so each user has an unique id. I'm having trouble understanding what concept I should use to share trip1 with user2. I found out documentReferences allow you to share the specific path of the trip with other users but it doesn't necessarily add the trip to user2 so they can see it on their dashboard. Is documentReferences the correct way to share data with other users?

Data structure

Upvotes: 5

Views: 2472

Answers (1)

CoderUni
CoderUni

Reputation: 6134

The best way to do this is to create another collection with the name trips or something you want. It is better to separate the user's data and the trip's data since you are going to share it from one user to another. You can create a unique document for trip 1 and add the location's name as trip 1's value. This way you can filter out where each specific trip is by using .where(). Inside trip1 you can store the reviews of each user inside it. Watch these two videos so that you will be able to understand how to implement it: https://www.youtube.com/watch?v=Ofux_4c94FI and https://www.youtube.com/watch?v=haMOUb3KVSo. Good Luck!

Upvotes: 3

Related Questions