Ronin Spect
Ronin Spect

Reputation: 57

how can one user modify a data in firestore which will not affect other user data in the app?

I am new to flutter(and coding),I don't know if I specified the question clearly but what I want is for when a user "Follows" or "subscribe" to a product it goes to a listview but it changing the data globally in firestore, so in every user's listview has the same data subscribed. I want make it personalized for that specific user only, other can change the data too which will only affect that specific user only,

think of it as ecommerce cart function where every user has different thing in the cart

I did make a collection for "product" but every user getting data from same collection and it changing globally.

how can I make common subscribed data personalized for each user which will not conflict with others data.

Upvotes: 0

Views: 46

Answers (1)

MendelG
MendelG

Reputation: 20008

how can I make common subscribed data personalized for each user which will not conflict with others data.

Every Firebase user has an id, you can use the user's id and set/query documents based on that.

For example, to set the data:

.collection('bla').doc(USER_ID).set({"name": "John"})

and to retrieve the data based on the id:

final snapshot = await Firestore.instance
    .collection('bla')
    .doc(USER_ID)
    .get();

See also

Upvotes: 1

Related Questions