emreoktem
emreoktem

Reputation: 2547

Querying a list in Firebase Firestore

I am using Firebase Firestore database in my project. I have a data structure as below:

I need to write a query which finds the users with a specific person in the following people part of the document fields.

For example if I query for the users which following person0 both user1 and user2 will be returned according to my example above.

Any suggestion will be appreciated.

Upvotes: 0

Views: 2618

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598728

Storing the followingPeople in an array is an anti-pattern. Please read the Firestore documentation on working with arrays, lists and sets for a better approach.

followingPeople: {
    "person0": true,
    "person1": true,
    "person2": true
}

I'd also recommend reading my answer to http://stackoverflow.com/questions/40656589/firebase-query-if-child-of-child-contains-a-value. While it was written for the Firebase Realtime Database, the same logic applies here.

Upvotes: 1

Related Questions