fungous_bread
fungous_bread

Reputation: 29

How to use `where` query to search for contents present in an array from Cloud Firestore using Flutter?

The code which I am trying to write is

var username = ["user1", "user2", "user3", "user4", "user5",
                "user6", "user7", "user8", "user9", "user10",
                "user11", "user12", "user13", "user14", "user15"];
await Firestore.instance.collection("uploads").where("name", isEqualTo: username).get()

Yet I am not able to get the documents from Firestore. How can this be solved?

Upvotes: 0

Views: 37

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317712

If you're trying to search for a value among an array of possible values, an isEqualTo query is not going to work. Consider instead a whereIn query instead.

However, since you have 15 items here, and whereIn is limited to 10, you will have to make multiple queries (either for individual documents, or batched by no more than 10) and merge the results in the app.

Upvotes: 1

Related Questions