Documentation ¶
Index ¶
- Constants
- Variables
- type ApiUser
- type Connection
- type Database
- func (db *Database) Exec(sql string, values ...interface{}) (rows int, err error)
- func (db *Database) FileAdd(file *File) (caught try.Err)
- func (db *Database) FileByHash(hash string) (file *File, caught try.Err)
- func (db *Database) FileByID(id uint) (file *File, caught try.Err)
- func (db *Database) FileHashExists(hash string) (exists bool, caught try.Err)
- func (db *Database) FilesCount(query ...interface{}) (count int64, caught try.Err)
- func (db *Database) FilesDeleteOrphans() (caught try.Err)
- func (db *Database) FilesGet(query ...interface{}) (files []*File, caught try.Err)
- func (db *Database) FilesGetOrphans() (files []*File, caught try.Err)
- func (db *Database) GetDialect() string
- func (db *Database) GetVersion() (version string, caught try.Err)
- func (db *Database) IsDialect(dialect string) bool
- func (db *Database) Migrate(printCmds bool) (caught try.Err)
- func (db *Database) UserAdd(user *User) (caught try.Err)
- func (db *Database) UserByID(id uint) (user *User, caught try.Err)
- func (db *Database) UserByName(name string) (user *User, caught try.Err)
- func (db *Database) UserDeleteByID(id uint) (caught try.Err)
- func (db *Database) UserNameExists(name string) (exists bool, caught try.Err)
- func (db *Database) UserUpdate(user *User) (caught try.Err)
- func (db *Database) UsersCount(query ...interface{}) (count int64, caught try.Err)
- func (db *Database) UsersGet(query ...interface{}) (users []*User, caught try.Err)
- func (db *Database) VersionAdd(version *Version) (caught try.Err)
- func (db *Database) VersionByID(id uint, deep bool) (version *Version, caught try.Err)
- func (db *Database) VersionDeleteByID(id uint) (caught try.Err)
- func (db *Database) VersionFileAdd(versionFile *VersionFile) (caught try.Err)
- func (db *Database) VersionFileByID(id uint, deep bool) (versionFile *VersionFile, caught try.Err)
- func (db *Database) VersionFileByPath(versionId uint, filePath string) (versionFile *VersionFile, caught try.Err)
- func (db *Database) VersionFilesCount(query ...interface{}) (count int64, caught try.Err)
- func (db *Database) VersionFilesGet(deep bool, query ...interface{}) (versionFiles []*VersionFile, caught try.Err)
- func (db *Database) VersionIDByWebsite(websiteId uint, versionName string) (versionId uint, caught try.Err)
- func (db *Database) VersionUpdate(version *Version) (caught try.Err)
- func (db *Database) VersionsCount(query ...interface{}) (count int64, caught try.Err)
- func (db *Database) VersionsGet(deep bool, query ...interface{}) (versions []*Version, caught try.Err)
- func (db *Database) WebsiteAdd(website *Website) (caught try.Err)
- func (db *Database) WebsiteByID(id uint, deep bool) (website *Website, caught try.Err)
- func (db *Database) WebsiteByPath(sitePath string, deep bool) (website *Website, caught try.Err)
- func (db *Database) WebsiteDeleteByID(id uint) (caught try.Err)
- func (db *Database) WebsitePathExists(sitePath string) (exists bool, caught try.Err)
- func (db *Database) WebsiteUpdate(website *Website) (caught try.Err)
- func (db *Database) WebsitesCount(query ...interface{}) (count int, caught try.Err)
- func (db *Database) WebsitesGet(deep bool, query ...interface{}) (websites []*Website, caught try.Err)
- type File
- type Permission
- type User
- type Version
- type VersionFile
- type Website
Constants ¶
View Source
const ( DialectSqlite = "sqlite" DialectMySql = "mysql" DialectPostgres = "postgres" )
View Source
const ( VISIBILITY_HIDDEN = 1 VISIBILITY_SEARCHABLE = 2 VISIBILITY_VISIBLE = 3 )
Variables ¶
View Source
var ( ErrEmptyDbUsername = errors.New("empty db username") ErrEmptyDbPassword = errors.New("empty db password") ErrEmptyDbName = errors.New("empty db name") ErrUnknownSqlDialect = errors.New( "unknown dialect (allowed: sqlite, mysql, postgres)") ErrUsernameAlreadyExists = errors.New("username already exists") ErrSitePathAlreadyExists = errors.New("website path already exists") ErrVersionNameAlreadyExists = errors.New("version name already exists in website") ErrVersionFileAlreadyExists = errors.New("version file already exists in version") ErrEmptyUser = errors.New("user empty") ErrEmptyWebsite = errors.New("website empty") ErrEmptyVersion = errors.New("version empty") ErrEmptyFile = errors.New("file empty") )
View Source
var AllModels = []interface{}{ &Website{}, &Version{}, &VersionFile{}, &File{}, &User{}, &ApiUser{}, &Permission{}, }
View Source
var TableNames = []string{
"version_files",
"versions",
"websites",
"files",
"api_users",
"users",
"permissions",
}
Functions ¶
This section is empty.
Types ¶
type ApiUser ¶
type ApiUser struct { ID uint `gorm:"primary_key;unique_index;not null;auto_increment"` KeyHash string `gorm:"type:varchar(200);not null"` CreatedAt time.Time `` Creator *User `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` CreatorID uint `` Permission *Permission `gorm:"constraint:OnUpdate:CASCADE,OnDelete:RESTRICT"` PermissionID uint `` }
type Connection ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func (*Database) FileByHash ¶
func (*Database) FileHashExists ¶
func (*Database) FilesCount ¶
func (*Database) FilesDeleteOrphans ¶
func (*Database) FilesGetOrphans ¶
func (*Database) GetDialect ¶
func (*Database) UserByName ¶
func (*Database) UserNameExists ¶
func (*Database) UsersCount ¶
func (*Database) VersionByID ¶
func (*Database) VersionDeleteByID ¶
func (*Database) VersionFileAdd ¶
func (db *Database) VersionFileAdd(versionFile *VersionFile) (caught try.Err)
func (*Database) VersionFileByID ¶
func (*Database) VersionFileByPath ¶
func (*Database) VersionFilesCount ¶
func (*Database) VersionFilesGet ¶
func (db *Database) VersionFilesGet(deep bool, query ...interface{}) ( versionFiles []*VersionFile, caught try.Err)
func (*Database) VersionIDByWebsite ¶
func (*Database) VersionUpdate ¶
func (*Database) VersionsCount ¶
func (*Database) VersionsGet ¶
func (*Database) WebsiteByID ¶
func (*Database) WebsiteByPath ¶
func (*Database) WebsiteDeleteByID ¶
func (*Database) WebsitePathExists ¶
func (*Database) WebsiteUpdate ¶
func (*Database) WebsitesCount ¶
type Permission ¶
type User ¶
type User struct { ID uint `gorm:"primary_key;unique_index;not null;auto_increment"` Name string `gorm:"type:varchar(50);not null;unique_index"` PasswordHash string `gorm:"type:varchar(200);not null"` CreatedAt time.Time `` Permission *Permission `gorm:"constraint:OnUpdate:CASCADE,OnDelete:RESTRICT"` PermissionID uint `` }
type Version ¶
type Version struct { ID uint `gorm:"primary_key;unique_index;not null;auto_increment"` Name string `gorm:"type:varchar(200);not null"` Tags string `gorm:"type:varchar(1000);not null"` Website *Website `` WebsiteID uint `` User *User `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL"` UserID uint `` CreatedAt time.Time `` Files []VersionFile `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` }
type VersionFile ¶
type VersionFile struct { ID uint `gorm:"primary_key;unique_index;not null;auto_increment"` Path string `gorm:"type:varchar(200);not null"` Version *Version `gorm:"constraint:OnUpdate:CASCADE,OnDelete:RESTRICT"` VersionID uint `` File *File `gorm:"constraint:OnUpdate:CASCADE,OnDelete:RESTRICT"` FileID uint `` }
type Website ¶
type Website struct { ID uint `gorm:"primary_key;unique_index;not null;auto_increment"` Name string `gorm:"type:varchar(200);not null"` Path string `gorm:"type:varchar(200);not null"` PathLower string `gorm:"type:varchar(200);not null;unique_index"` Logo *File `gorm:"constraint:OnUpdate:CASCADE,OnDelete:RESTRICT"` LogoID sql.NullInt64 `gorm:"type:uint"` Color string `gorm:"type:varchar(20);not null"` Visibility int `` User *User `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL"` UserID uint `` CreatedAt time.Time `` MaxVersions int `` SourceUrl string `gorm:"type:varchar(200);not null"` SourceType string `gorm:"type:varchar(20);not null"` Versions []Version `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` }
Click to show internal directories.
Click to hide internal directories.