Firestore Data Model Firestore database model for kanban boards and backend security rules.

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


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

Or Signup for Unlimited PRO Access

Model the data in Firestore for the Kanban feature.

Learn more about Data Modeling in Firestore.

Data Model

file_type_ng_component_ts board.model.ts
export interface Board {
    id?: string;
    title?: string;
    priority?: number;
    tasks?: Task[];
  }

export interface Task {
    description?: string;
    label?: 'purple' | 'blue' | 'green' | 'yellow' | 'red' | 'gray';
}

Firestore Security Rules

file_type_firebase firebase rules
rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /boards/{document} {
    
      allow read;
      allow create: if requestMatchesUID();
      allow update: if resourceMatchesUID() && requestMatchesUID();
      allow delete: if resourceMatchesUID(); 
    }
    
    function requestMatchesUID() {
        return request.auth.uid == request.resource.data.uid;
    }

    function resourceMatchesUID() {
        return request.auth.uid == resource.data.uid;
    }
    
  }
}

Q&A Chat