Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to add comments to Firebase Firestore rules?

I've been unable to find anything in the docs that say whether you can add comments, i.e.

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      // Testing the removal of this line:
      // allow read: if true;
      allow read: if false;
      allow write: if request.auth.uid != null;
    }
  }
}

Is there any info online about the rules syntax? What language is it written in?

like image 504
Djave Avatar asked Apr 11 '20 07:04

Djave


People also ask

How do I modify Firebase rules?

Edit and update your rulesOpen the Firebase console and select your project. Then, select Realtime Database, Cloud Firestore or Storage from the product navigation, then click Rules to navigate to the Rules editor. Edit your rules directly in the editor.

How do I edit a rule in firestore?

Use the Firebase console To set up and deploy your first set of rules, open the Rules tab in the Cloud Firestore section of the Firebase console. Write your rules in the online editor, then click Publish.

What language is Firebase rules written in?

In Realtime Database, Firebase Security Rules consist of JavaScript-like expressions contained in a JSON document.

How do I build a comment system using Firebase?

Go to Firebase, and sign up for a Google account. If you don't have one, then click “Get Started”. Click on “Add Project” to add a new project. Add a name for your project, and click “Create a project”.


1 Answers

The language is documented here. It's called CEL (common expression language). It's pretty clear from what you see that lines containing // are considered like C++ and Java to be comments from the point of // to the end of the line.

like image 104
Doug Stevenson Avatar answered Sep 27 '22 17:09

Doug Stevenson