简体   繁体   中英

Llimit count of data reads per user firebase and firestore in flutter

I am developing an application that provides business reports hosted on an AWS virtual machine to registered users through Firebase with a user profile in Firestore. Each time the user makes a query, the number of queries increases in his Firestore profile (code attached). I would need that users can not make more than 10 daily queries .. how can I do it?

code :

child: FlatButton(
        color: Colors.transparent,
        child: Text(
          'Process',
          style: TextStyle(color: Colors.white),
        ),
        onPressed: () async {
          final FirebaseUser user =
              await _auth.currentUser();

          var loginSuccess = await model
              .getdata(_inputCuit.text);
          if (loginSuccess) {
            
            Firestore.instance
                .collection("users")
                .document(user.uid)
                .updateData({
              "queries": FieldValue.increment(1)
            });

            
            Navigator.pushNamed(context, 'post',
                arguments: model.info);

enter image description here

There is no way in security rules to limit the number of reads a user makes. If that is a requirement for your use-case, you'll have to implement the reads in Cloud Functions or some other trusted environment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM