a mini social media app for small communities
1# database spec 2 3i have a mental map of the databases in use for beep, but that does not mean 4others also do. along with that, having a visual representation is probably 5going to be pretty useful. so with that said, i present to you, the database 6spec for beep: 7 8## `User` 9 10> represents a registered user 11 12| name | type | desc | 13|-----------------|-----------|--------------------------------------------------| 14| `id` | int | identifier this user on the backend | 15| `username` | string | identifier this user on the frontend | 16| `nickname` | ?string | optional nickname for this user on the frontend | 17| `password` | string | hashed and salted password for this user | 18| `password_salt` | string | salt for this user's password | 19| `muted` | bool | controls whether or not this user can make posts | 20| `admin` | bool | controls whether or not this user is an admin | 21| `theme` | ?string | controls per-user css themes | 22| `bio` | string | bio for this user | 23| `pronouns` | string | pronouns for this user | 24| `created_at` | time.Time | a timestamp of when this user was made | 25 26## `Post` 27 28> represents a public post 29 30| name | type | desc | 31|-------------|-----------|----------------------------------------| 32| `id` | int | identifier for this post | 33| `author_id` | int | id of the user that authored this post | 34| `title` | string | the title of this post | 35| `body` | string | the body of this post | 36| `posted_at` | time.Time | a timestamp of when this post was made | 37 38## `Like` 39 40> represents all likes and dislikes on posts for this beep instance 41 42| name | type | desc | 43|-----------|------|------------------------------------------------| 44| `id` | int | identifier for this (dis)like | 45| `user_id` | int | the user that sent this (dis)like | 46| `post_id` | int | the post this (dis)like is for | 47| `is_like` | bool | `true` if this is a like, `false` if a dislike | 48 49## `LikeCache` 50 51> stores total likes for a post 52 53<!-- todo: implement this --> 54<!-- > a post with no likes nor dislikes will not be in this table --> 55<!-- > the data in this table is cleared and recalculated every 56> `config:post:likes_refresh_minutes` minutes --> 57 58| name | type | desc | 59|-----------|------|---------------------------------------| 60| `id` | int | identifier for this entry | 61| `post_id` | int | the post this entry is for | 62| `likes` | int | the net amount of likes this post has |