0

Is it possible to query documents fields against an array of values where it would return the fields which contain one of the array elements values

                 _fireStore
                .collection('articles')
                .orderBy('created')
                .where('projectName', isEqualTo: listHearted)
                .getDocuments()
                .asStream(),
1
  • It's not clear what you're asking. Please edit the question to show examples of what documents you might expect to receive from a query. Commented Oct 19, 2019 at 12:41

2 Answers 2

1

There is currently no way to perform a query that returns items that match one of a number of values in a certain field. The workaround is to perform a query for each hearted project, and merge the results on the client.

Also see:

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

Comments

1

i've done it using a stream within a stream.

 Stream<List<DocumentSnapshot>> streamDoc;
  StreamController<List<DocumentSnapshot>> controller =
  StreamController<List<DocumentSnapshot>>();

 void docRef() {
Firestore _fireStore = Firestore.instance;

Stream<QuerySnapshot> snapshot = _fireStore
    .collection('articles')
    .orderBy('created')
    .getDocuments()
    .asStream();

List<DocumentSnapshot> listDoc = List<DocumentSnapshot>();
snapshot.listen((snapshot) {
  snapshot.documents.forEach((e) {
    if (SharedPrefList.listHearted
            .contains(e.data['projectName'].toString()) &&
        widget.type == 'hearted') {
      listDoc.add(e);
      controller.add(listDoc);
    }
    if (SharedPrefList.listSeen
            .contains(e.data['projectName'].toString()) &&
        widget.type == 'seen') {
      listDoc.add(e);
      controller.add(listDoc);
    }
  });
});

}

Comments

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.