feat(sources): finalized model with gorm annotation
Signed-off-by: SoXX <soxx@fenpa.ws>
This commit is contained in:
parent
21b43333d0
commit
5a693063bb
@ -7,8 +7,11 @@ import (
|
||||
// Post model
|
||||
type Post struct {
|
||||
BaseModel
|
||||
Rating models.Rating `gorm:"type:rating"`
|
||||
Body string `gorm:"type:text"`
|
||||
UserID int `gorm:"index"`
|
||||
Status string `gorm:"type:post_status"`
|
||||
Rating models.Rating `gorm:"type:enum('safe','questionable','explicit')"`
|
||||
Body string `gorm:"type:text"`
|
||||
UserID int
|
||||
Status string
|
||||
Tags []Tag `gorm:"many2many:post_tags;"`
|
||||
Favorites []UserFavorite `gorm:"foreignKey:PostID"`
|
||||
References []PostReference `gorm:"foreignKey:PostID"`
|
||||
}
|
||||
|
8
pkg/models/pgModels/postReference.go
Normal file
8
pkg/models/pgModels/postReference.go
Normal file
@ -0,0 +1,8 @@
|
||||
package pgModels
|
||||
|
||||
type PostReference struct {
|
||||
PostID string `gorm:"primaryKey"`
|
||||
SourceID string `gorm:"primaryKey"`
|
||||
URL string `gorm:"not null;unique"`
|
||||
SourcePostID string
|
||||
}
|
@ -3,6 +3,8 @@ package pgModels
|
||||
// Source model
|
||||
type Source struct {
|
||||
BaseModel
|
||||
DisplayName string `gorm:"type:text"`
|
||||
Domain string `gorm:"type:text;not null;unique"`
|
||||
DisplayName string
|
||||
Domain string `gorm:"not null;unique"`
|
||||
UserSources []UserSource `gorm:"foreignKey:SourceID"`
|
||||
References []PostReference `gorm:"foreignKey:SourceID"`
|
||||
}
|
||||
|
@ -4,18 +4,21 @@ import "git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
|
||||
// Tag models
|
||||
type Tag struct {
|
||||
Name string `gorm:"primaryKey"`
|
||||
Type models.TagType `gorm:"type:tag_type"`
|
||||
Name string `gorm:"primaryKey"`
|
||||
Type models.TagType
|
||||
Aliases []TagAlias `gorm:"foreignKey:TagID"`
|
||||
Groups []TagGroup `gorm:"foreignKey:TagID"`
|
||||
Posts []Post `gorm:"many2many:post_tags;"`
|
||||
}
|
||||
|
||||
// TagAlias model
|
||||
type TagAlias struct {
|
||||
Name string `gorm:"primaryKey"`
|
||||
TagID string `gorm:"index"`
|
||||
TagID string
|
||||
}
|
||||
|
||||
// TagGroup model
|
||||
type TagGroup struct {
|
||||
Name string `gorm:"primaryKey"`
|
||||
TagID string `gorm:"index"`
|
||||
TagID string
|
||||
}
|
||||
|
@ -3,4 +3,6 @@ package pgModels
|
||||
// User model
|
||||
type User struct {
|
||||
BaseModel
|
||||
Favorites []UserFavorite `gorm:"foreignKey:UserID"`
|
||||
Sources []UserSource `gorm:"foreignKey:UserID"`
|
||||
}
|
||||
|
9
pkg/models/pgModels/userFavorite.go
Normal file
9
pkg/models/pgModels/userFavorite.go
Normal file
@ -0,0 +1,9 @@
|
||||
package pgModels
|
||||
|
||||
import "time"
|
||||
|
||||
type UserFavorite struct {
|
||||
UserID string `gorm:"primaryKey"`
|
||||
PostID string `gorm:"primaryKey"`
|
||||
CreatedAt time.Time
|
||||
}
|
8
pkg/models/pgModels/userSource.go
Normal file
8
pkg/models/pgModels/userSource.go
Normal file
@ -0,0 +1,8 @@
|
||||
package pgModels
|
||||
|
||||
type UserSource struct {
|
||||
UserID string `gorm:"primaryKey"`
|
||||
SourceID string `gorm:"primaryKey"`
|
||||
AccountUsername string
|
||||
AccountID string
|
||||
}
|
Reference in New Issue
Block a user