Common Examples Simple, yet useful Firestore rules examples

This lesson is available for PRO members or as a single course purchase. Sign-in and choose a plan below.
Get Unlimited PRO Access

OR


*Enrollment provides full access to this course (and updates) for life.

file_type_firebase firestore.rules
match /users/{userId} {

    allow read: if request.auth.uid != null;
    allow write: if request.auth.uid == userId;

}

match /todos/{docId} {

    allow read: if resource.data.status == 'published';

    allow create: if request.auth.uid == request.resource.data.uid 
                && request.time == request.resource.data.createdAt;
                

    allow update: if request.auth.uid == resource.data.uid 
                && request.resource.data.keys().hasOnly(['text', 'status']);
}

Q&A Chat