💾 Data Model
How to model data relationships between users, posts, and hearts
Database Structure
users/{uid}
Public user profileusernames/{username}
Username uniqueness trackingusers/{uid}/posts/{slug}
User can have many postsusers/{uid}/posts/{slug}/hearts/{uid}
many-to-many relationship between users and posts via hearts
Data Model for Posts
Example post document with all expected fields.
// users/{uid}/posts/{slug}
{
title: 'Hello World,
slug: 'hello-world',
uid: 'userID',
username: 'jeffd23',
published: false,
content: '# hello world!',
createdAt: TimeStamp,
updatedAt: TimeStamp,
heartCount: 0,
}