Home > Mobile >  How to query firebase firestore with condition
How to query firebase firestore with condition

Time:08-16

I have this function

Future<Member?> readMember() async {
  final docMember = FirebaseFirestore.instance
      .collection('users')
      .doc(any)
      .collection('phone_number')
      .doc('1234567890');

  final snapshot = await docMember.get();
}

What I actually wanted to do is to query the documents under the collection users then search all the documents against one that contains 1234567890 as the phone_number field.

I need help on this.

CodePudding user response:

Future<Member?> readMember() async {
  final docMember = FirebaseFirestore.instance
    .collection('users').where('id', isEqualTo: '1234567890');

  final snapshot = await docMember.get();
}
  • Related