Skip to content

Commit

Permalink
feat: fixes race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
TalentedB committed Sep 8, 2023
2 parents 204b1c5 + 385cb21 commit 76650a0
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions db/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,33 +197,33 @@ type SchoolFollow struct {

// ! Very important that SOME FIELDS ARE NOT EVER SERIALIZED TO PROTECT SENSATIVE DATA (json:"-")
type Post struct {
ID EncryptedID `gorm:"primary_key;column:id" json:"id"`
CreatedAt TimeMicros `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt TimeMicros `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
UserID string `gorm:"column:user_id" json:"-"`
SchoolID EncryptedID `gorm:"column:school_id" json:"-"`
School School `gorm:"foreignKey:SchoolID" json:"school"`
FacultyID *EncryptedID `gorm:"column:faculty_id" json:"-"`
Faculty Faculty `gorm:"foreignKey:FacultyID" json:"faculty"`
YearOfStudyID *EncryptedID `gorm:"column:year_of_study_id" json:"-"`
YearOfStudy YearOfStudy `gorm:"foreignKey:YearOfStudyID" json:"year_of_study"`
Title string `gorm:"column:title" json:"title"`
Content string `gorm:"column:content" json:"content"`
Downvote uint `gorm:"column:downvote" json:"downvote"`
Upvote uint `gorm:"column:upvote" json:"upvote"`
VoteScore int `gorm:"column:vote_score" json:"-"` // redundant to return to the user
TrendingScore float64 `gorm:"column:trending_score" json:"trending_score"`
HottestOn *datatypes.Date `gorm:"column:hottest_on" json:"hottest_on"` // intentionally a pointer, so that it defaults to NULL when created and not specified (i.e. not its zero-value)
Hidden bool `gorm:"column:hidden" json:"hidden"`
Sentiment *float64 `gorm:"column:sentiment" json:"sentiment"`
ReportCount uint `gorm:"column:report_count" json:"-"`
ReviewedByMod bool `gorm:"column:reviewed_by_mod" json:"-"`
Edited bool `gorm:"column:edited" json:"edited"`
CategoryID EncryptedID `gorm:"column:category_id" json:"-"`
Category PostCategory `gorm:"foreignKey:CategoryID" json:"category"`
CommentCount uint `gorm:"column:comment_count" json:"comment_count"`
ID EncryptedID `gorm:"primary_key;column:id" json:"id"`
CreatedAt TimeMicros `gorm:"column:created_at;autoCreateTime" json:"created_at"`
UpdatedAt TimeMicros `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`
UserID string `gorm:"column:user_id" json:"-"`
SchoolID EncryptedID `gorm:"column:school_id" json:"-"`
School School `gorm:"foreignKey:SchoolID" json:"school"`
FacultyID *EncryptedID `gorm:"column:faculty_id" json:"-"`
Faculty Faculty `gorm:"foreignKey:FacultyID" json:"faculty"`
YearOfStudyID *EncryptedID `gorm:"column:year_of_study_id" json:"-"`
YearOfStudy YearOfStudy `gorm:"foreignKey:YearOfStudyID" json:"year_of_study"`
Title string `gorm:"column:title" json:"title"`
Content string `gorm:"column:content" json:"content"`
Downvote uint `gorm:"column:downvote" json:"downvote"`
Upvote uint `gorm:"column:upvote" json:"upvote"`
VoteScore int `gorm:"column:vote_score" json:"-"` // redundant to return to the user
TrendingScore float64 `gorm:"column:trending_score" json:"trending_score"`
HottestOn *datatypes.Date `gorm:"column:hottest_on" json:"hottest_on"` // intentionally a pointer, so that it defaults to NULL when created and not specified (i.e. not its zero-value)
Hidden bool `gorm:"column:hidden" json:"hidden"`
Sentiment *float64 `gorm:"column:sentiment" json:"sentiment"`
ReportCount uint `gorm:"column:report_count" json:"-"`
ReviewedByMod bool `gorm:"column:reviewed_by_mod" json:"-"`
Edited bool `gorm:"column:edited" json:"edited"`
CategoryID EncryptedID `gorm:"column:category_id" json:"-"`
Category PostCategory `gorm:"foreignKey:CategoryID" json:"category"`
CommentCount uint `gorm:"column:comment_count" json:"comment_count"`
CommentNumerics uint `gorm:"column:comment_numerics" json:"comment_numerics"`
ImgUrls PgTxtArr `gorm:"column:img_urls" json:"img_urls"`
ImgUrls PgTxtArr `gorm:"column:img_urls" json:"img_urls"`
}

// ! Very important that SOME FIELDS ARE NOT EVER SERIALIZED TO PROTECT SENSATIVE DATA (json:"-")
Expand Down

0 comments on commit 76650a0

Please sign in to comment.