๐Ÿ”‘ Common Examples

Simple, yet useful Firestore rules examples

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']);
}

Questions? Let's chat

Open Discord