Jenyus-Org / recog-api

API for the Swiss school forum to connect business acquaintances across the country.
4 stars 0 forks source link

[ENHANCEMENT] Base Models #3

Closed Dan6erbond closed 3 years ago

Dan6erbond commented 3 years ago

Create base models required by the core functionality of Recog; users, posts, and flairs.

This commit includes TypeORM migrations which can be ran using yarn typeorm migration:run, using the yarn script allows TypeORM to use Typescript instead of pure Js.

Model Overview

User

The base user model is currently setup with the default username/password combination, which may change in the future depending on authentication flows.

Also contains a relationship to posts using the author_id attribute on Post, see more below.

Post

The Post entity represents simple posts with a title, markdown body and meta fields, such as author corresponding to the User model which created the post, and a many-to-many relationship to the Flair entity, see more below.

Flair

Flairs are used to group posts, the entity contains fields for value and color, with a many-to-many relationship to Posts using a join table, and a custom entity to map IDs, PostToFlair.