Home > other >  async function not completing when querying FirebaseFirestore
async function not completing when querying FirebaseFirestore

Time:11-06

See the print statement down below. It never executes.


  Future<void> populate() async {
    final userId = FirebaseAuth.instance.currentUser!.uid;

    final db = FirebaseFirestore.instance;
    // Get list of ids of parties use swiped on.
    var snapshot1 = await db
        .collection("partiers_swipes")
        .where('userId', isEqualTo: userId)
        .get();

    var partyIdsUserSwipesOn = [];
    if (snapshot1.size > 0) {
      snapshot1.docs.forEach((element) {
        partyIdsUserSwipesOn.add(element.data()['partyId']);
      });
    }

    var snapshot2 = await db
        .collection("parties")
        .where(FieldPath.documentId, whereNotIn: partyIdsUserSwipesOn)
        .get();
    print('This never executes');
  }

CodePudding user response:

The whereNotIn argument is not supported by the where clause. This crashes the function.

  • Related