0

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.

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

This won't work. XD You are creating a doc where the user ID is the same as document ID. And then you search for a document which contains a field "user_id".
Now it's ok if you want to, you can show him a second way where he can have a field in a document and use .where('user_id', isEqualTo: USER_ID) query.
@Mises Thanks. This code was just an example to get the OP started. not really an in-depth answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.