skip to Main Content
 QuerySnapshot querySnapshot = await FirebaseFirestore.instance
    .collection('stations')
    .where('norequest', isGreaterThan: 9)
    .get();

Here i want get if ‘norequest’ is a whole number like 10 , 20 , 30 , 40 something like this and greater than 5 ? How can i get that

2

Answers


  1. try this query:

    QuerySnapshot querySnapshot = await FirebaseFirestore.instance
        .collection('stations')
        .where('norequest', isGreaterThan: 5)
        .where("norequest", whereIn: [10, 20, 30, 40])    
        .get();
    
    Login or Signup to reply.
  2. Future<List<YourModel>> getData() async {
      List<YourModel> yourModel = [];
      QuerySnapshot querySnapshot =
          await FirebaseFirestore.instance.collection('stations').where("norequest", isGreaterThan: 5).get();
      if (querySnapshot?.docs != null) {
        querySnapshot.docs.map((x) {
          if (int.parse(x.data()['norequest'].toString()) % 10 == 0) {
            yourModel.add(YourModel.fromJson(x.data()));
          }
        });
      }
      return yourModel;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search