rules_version = '2';

service cloud.firestore {
  match /databases/{database}/documents {

    match /childrens/{userId} {
      allow read, write: if request.auth != null
                         && request.auth.uid == userId;

      match /{document=**} {
        allow read, write: if request.auth != null
                           && request.auth.uid == userId;
      }
    }

    match /books/{bookId} {
      allow read, write: if request.auth != null;
    }
    
    match /flashcards/{flashcardId} {
        allow read, write: if request.auth != null;
    }
    
    match /metadata/{docId} {
      allow read: if request.auth != null;
      allow write: if true;
    }
    
  }
}
