🔥 Firestore Data Model
Firestore database model for kanban boards and backend security rules.
Model the data in Firestore for the Kanban feature.
Learn more about Data Modeling in Firestore.
Data Model
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
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;
}
}
}