0

enter image description here


enter image description here

I need to fetch documents that 'uid', isEqualTo: 'IeXbRCpmB8ejUdYh7nn4IQ2HgUC3'

Above list is containing maps.

How can I do this on flutter?

I tried below code but it's giving No Data as output.

StreamBuilder<QuerySnapshot>(
      stream: FirebaseFirestore.instance
          .collection('abc')
          .where('list.uid', isEqualTo: 'ijQS0rKB4aOJSoTKy1zvmy8O9me2')
          .snapshots(),
      builder: (context, snapshot) {
        if (snapshot.hasError) {
          return const Center(child: Text('Something wrong!'));
        }

        if (snapshot.connectionState == ConnectionState.waiting) {
          return const Center(child: CircularProgressIndicator());
        }

        if (snapshot.data!.size == 0) {
          return const Center(
            child: Text('No Data'),
          );
        }

        return const Center(child: Text('Done'));
      },
    )

How do I perform this query?

2
  • You can't. You will have to use one of the alternatives in the duplicates. Commented Nov 3, 2022 at 3:24
  • While you can query an array for complete matches (with array-contains), you can't query on a partial match of an item in an array. If you want to be able to query on just the UID, consider having an additional field (e.g. listUIDs) with just those values and then using array-contains on that. Commented Nov 3, 2022 at 3:24

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.