postgres

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2022 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithDB

func ContextWithDB(ctx context.Context, db *gorm.DB) context.Context

func CreateVersion

func CreateVersion(ctx context.Context, version *Version) error

func DBCtx

func DBCtx(ctx context.Context) *gorm.DB

func DBFromContext

func DBFromContext(ctx context.Context) *gorm.DB

func Delete

func Delete(ctx context.Context, object interface{})

func DeleteForced

func DeleteForced(ctx context.Context, object interface{})

func DeleteMod

func DeleteMod(ctx context.Context, modID string)

func GetBootstrapVersionCount

func GetBootstrapVersionCount(ctx context.Context, filter *models.BootstrapVersionFilter) int64

func GetGuideCount

func GetGuideCount(ctx context.Context, filter *models.GuideFilter) int64

func GetModCount

func GetModCount(ctx context.Context, search string, unapproved bool) int64

func GetModCountNew

func GetModCountNew(ctx context.Context, filter *models.ModFilter, unapproved bool) int64

func GetModLatestVersions

func GetModLatestVersions(ctx context.Context, modID string, unapproved bool) *[]Version

func GetModsLatestVersions

func GetModsLatestVersions(ctx context.Context, modIds []string, unapproved bool) *[]Version

func GetSMLLatestVersions

func GetSMLLatestVersions(ctx context.Context) *[]SMLVersion

func GetSMLVersionCount

func GetSMLVersionCount(ctx context.Context, filter *models.SMLVersionFilter) int64

func GetUserSession

func GetUserSession(ctx context.Context, oauthUser *oauth.UserData, userAgent string) (*UserSession, *User, bool)

func GetUsersByID

func GetUsersByID(ctx context.Context, userIds []string) *[]User

func GetVersionCountNew

func GetVersionCountNew(ctx context.Context, filter *models.VersionFilter, unapproved bool) int64

func IncrementGuideViews

func IncrementGuideViews(ctx context.Context, guide *Guide)

func IncrementModViews

func IncrementModViews(ctx context.Context, mod *Mod)

func IncrementVersionDownloads

func IncrementVersionDownloads(ctx context.Context, version *Version)

func InitializePostgres

func InitializePostgres(ctx context.Context)

func LogoutSession

func LogoutSession(ctx context.Context, token string)

func NewModQuery

func NewModQuery(ctx context.Context, filter *models.ModFilter, unapproved bool, count bool) *gorm.DB

func Save

func Save(ctx context.Context, object interface{})

func UserCanUploadModVersions

func UserCanUploadModVersions(ctx context.Context, user *User, modID string) bool

Types

type Announcement

type Announcement struct {
	SMRModel

	Message    string
	Importance string
}

func CreateAnnouncement

func CreateAnnouncement(ctx context.Context, announcement *Announcement) (*Announcement, error)

func GetAnnouncementByID

func GetAnnouncementByID(ctx context.Context, announcementID string) *Announcement

func GetAnnouncements

func GetAnnouncements(ctx context.Context) []Announcement

func GetAnnouncementsByImportance

func GetAnnouncementsByImportance(ctx context.Context, importance string) []Announcement

type BootstrapVersion

type BootstrapVersion struct {
	SMRModel

	Version             string `gorm:"type:varchar(32);unique_index"`
	SatisfactoryVersion int
	Stability           string `sql:"type:version_stability"`
	Date                time.Time
	Link                string
	Changelog           string
}

func CreateBootstrapVersion

func CreateBootstrapVersion(ctx context.Context, bootstrapVersion *BootstrapVersion) (*BootstrapVersion, error)

func GetBootstrapVersionByID

func GetBootstrapVersionByID(ctx context.Context, bootstrapVersionID string) *BootstrapVersion

func GetBootstrapVersions

func GetBootstrapVersions(ctx context.Context, filter *models.BootstrapVersionFilter) []BootstrapVersion

func GetBootstrapVersionsByID

func GetBootstrapVersionsByID(ctx context.Context, bootstrapVersionIds []string) []BootstrapVersion

type ContextDB

type ContextDB struct{}

type GormLogger

type GormLogger struct {
	SlowThreshold time.Duration
	Debug         bool
}

func (*GormLogger) Error

func (*GormLogger) Error(ctx context.Context, msg string, data ...interface{})

func (*GormLogger) Info

func (*GormLogger) Info(ctx context.Context, msg string, data ...interface{})

func (*GormLogger) LogMode

func (l *GormLogger) LogMode(mode logger.LogLevel) logger.Interface

func (*GormLogger) Trace

func (l *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

func (*GormLogger) Warn

func (*GormLogger) Warn(ctx context.Context, msg string, data ...interface{})

type Guide

type Guide struct {
	SMRModel

	Name             string `gorm:"type:varchar(50)"`
	ShortDescription string `gorm:"type:varchar(128)"`
	Guide            string
	Views            uint

	UserID string
	User   User
}

func CreateGuide

func CreateGuide(ctx context.Context, guide *Guide) (*Guide, error)

func GetGuideByID

func GetGuideByID(ctx context.Context, guideID string) *Guide

func GetGuides

func GetGuides(ctx context.Context, filter *models.GuideFilter) []Guide

func GetGuidesByID

func GetGuidesByID(ctx context.Context, guideIds []string) []Guide

func GetUserGuides

func GetUserGuides(ctx context.Context, userID string) []Guide

type Mod

type Mod struct {
	SMRModel

	Name             string `gorm:"type:varchar(32)"`
	ShortDescription string `gorm:"type:varchar(128)"`
	FullDescription  string
	SourceURL        string
	CreatorID        string
	Approved         bool `gorm:"default:false;not null"`
	Denied           bool `gorm:"default:false;not null"`
	Views            uint
	Downloads        uint
	Hotness          uint
	Popularity       uint
	LastVersionDate  *time.Time
	ModReference     string
	Hidden           bool

	Users []User `gorm:"many2many:user_mods;"`

	Versions []Version
}

func CreateMod

func CreateMod(ctx context.Context, mod *Mod) (*Mod, error)

func GetModByID

func GetModByID(ctx context.Context, modID string) *Mod

func GetModByIDOrReference

func GetModByIDOrReference(ctx context.Context, modIDOrReference string) *Mod

func GetModByReference

func GetModByReference(ctx context.Context, modReference string) *Mod

func GetMods

func GetMods(ctx context.Context, limit int, offset int, orderBy string, order string, search string, unapproved bool) []Mod

func GetModsByID

func GetModsByID(ctx context.Context, modIds []string) []Mod

func GetModsByIDOrReference added in v1.0.6

func GetModsByIDOrReference(ctx context.Context, modIDOrReferences []string) []Mod

func GetModsNew

func GetModsNew(ctx context.Context, filter *models.ModFilter, unapproved bool) []Mod

type SMLVersion

type SMLVersion struct {
	SMRModel

	Version             string `gorm:"type:varchar(32);unique_index"`
	SatisfactoryVersion int
	Stability           string `sql:"type:version_stability"`
	Date                time.Time
	Link                string
	Changelog           string
	BootstrapVersion    *string
}

func CreateSMLVersion

func CreateSMLVersion(ctx context.Context, smlVersion *SMLVersion) (*SMLVersion, error)

func GetSMLVersionByID

func GetSMLVersionByID(ctx context.Context, smlVersionID string) *SMLVersion

func GetSMLVersions

func GetSMLVersions(ctx context.Context, filter *models.SMLVersionFilter) []SMLVersion

func GetSMLVersionsByID

func GetSMLVersionsByID(ctx context.Context, smlVersionIds []string) []SMLVersion

type SMRDates

type SMRDates struct {
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type SMRModel

type SMRModel struct {
	ID string `gorm:"primary_key;type:varchar(14)"`
	SMRDates
}

type User

type User struct {
	SMRModel

	Email      string `gorm:"type:varchar(256);unique_index"`
	Username   string `gorm:"type:varchar(32)"`
	Avatar     string
	JoinedFrom string
	Banned     bool `gorm:"default:false;not null"`

	GithubID   *string
	GoogleID   *string
	FacebookID *string

	Mods []Mod `gorm:"many2many:user_mods;"`
}

func GetUserByID

func GetUserByID(ctx context.Context, userID string) *User

func GetUserByToken

func GetUserByToken(ctx context.Context, token string) *User

func (User) GetGroups

func (user User) GetGroups(ctx context.Context) []*auth.Group

func (User) GetRoles

func (user User) GetRoles(ctx context.Context) map[*auth.Role]bool

func (User) Has

func (user User) Has(ctx context.Context, role *auth.Role) bool

func (User) SetGroups

func (user User) SetGroups(ctx context.Context, groups []string)

type UserGroup

type UserGroup struct {
	SMRDates

	UserID  string `gorm:"primary_key"`
	GroupID string `gorm:"primary_key"`
}

type UserKey

type UserKey struct{}

type UserMod

type UserMod struct {
	UserID string `gorm:"primary_key"`
	ModID  string `gorm:"primary_key"`
	Role   string
}

func GetModAuthors

func GetModAuthors(ctx context.Context, modID string) []UserMod

func GetUserMods

func GetUserMods(ctx context.Context, userID string) []UserMod

type UserSession

type UserSession struct {
	SMRModel

	UserID string
	User   User

	Token     string `gorm:"type:varchar(256);unique_index"`
	UserAgent string
}

type Version

type Version struct {
	SMRModel

	ModID string

	Version      string `gorm:"type:varchar(16)"`
	SMLVersion   string `gorm:"type:varchar(16)"`
	Changelog    string
	Downloads    uint
	Key          string
	Stability    string `gorm:"default:'alpha'" sql:"type:version_stability"`
	Approved     bool   `gorm:"default:false;not null"`
	Denied       bool   `gorm:"default:false;not null"`
	Hotness      uint
	Metadata     *string
	ModReference *string
	VersionMajor *int
	VersionMinor *int
	VersionPatch *int
	Size         *int64
	Hash         *string
}

If updated, update dataloader

func GetModVersion

func GetModVersion(ctx context.Context, modID string, versionID string) *Version

func GetModVersionByName

func GetModVersionByName(ctx context.Context, modID string, versionName string) *Version

func GetModVersions

func GetModVersions(ctx context.Context, modID string, limit int, offset int, orderBy string, order string, unapproved bool) []Version

func GetModVersionsConstraint added in v1.0.6

func GetModVersionsConstraint(ctx context.Context, modID string, constraint string) []Version

func GetModVersionsNew

func GetModVersionsNew(ctx context.Context, modID string, filter *models.VersionFilter, unapproved bool) []Version

func GetVersion

func GetVersion(ctx context.Context, versionID string) *Version

func GetVersionsByID

func GetVersionsByID(ctx context.Context, versionIds []string) []Version

func GetVersionsNew

func GetVersionsNew(ctx context.Context, filter *models.VersionFilter, unapproved bool) []Version

type VersionDependency

type VersionDependency struct {
	SMRDates

	VersionID string `gorm:"primary_key;type:varchar(14)"`
	ModID     string `gorm:"primary_key;type:varchar(14)"`

	Condition string `gorm:"type:varchar(64)"`
	Optional  bool
}

func GetVersionDependencies

func GetVersionDependencies(ctx context.Context, versionID string) []VersionDependency

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL