How to limit a composite query in Firebase/flutter

Asked

Viewed 479 times

-1

I made a simple query this way and works correctly, it saves only once in the database, not repeating the same value.

  final QuerySnapshot result = await Future.value(Firestore.instance
      .collection("lockers")
      .where("numero_serie", isEqualTo: "$_numeroSerie")
      .limit(1)
      .getDocuments());

But I need to do a composite consultation and it’s not working, I tried it this way and it doesn’t save anything in the bank.

final QuerySnapshot result = await Future.value(Firestore.instance
    .collection("lockers")
    .where("userid", isEqualTo: "$_uid").limit(1)
    .where("numero_serie", isEqualTo: "$_numeroSerie").limit(1)
    .getDocuments()); 

So it saves the same value in the bank several times

final QuerySnapshot result = await Future.value(Firestore.instance
    .collection("lockers")
    .where("userid", isEqualTo: "$_uid")
    .where("numero_serie", isEqualTo: "$_numeroSerie").limit(1)
    .getDocuments());

1 answer

1


Browser other questions tagged

You are not signed in. Login or sign up in order to post.