db

package
v0.0.0-...-00bf402 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FolderTypeHotlink      = "hotlink"
	FolderTypeBrowsable    = "browsable"
	FolderTypeImageGallery = "gallery"
	FolderTypeVideoPlayer  = "player"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	*gorm.DB
}

Conn maintains a connection to the database.

func New

func New(dataDir string) (*Conn, error)

New attempts to connect to or create the database.

func (*Conn) Close

func (c *Conn) Close()

Close closes the database connection.

type Folder

type Folder struct {
	ID          int64     `gorm:"primaryKey" json:"id"`
	UUID        string    `gorm:"not null" json:"uuid"`
	Name        string    `gorm:"not null" json:"name"`
	Description string    `gorm:"not null" json:"description"`
	CreatedAt   time.Time `gorm:"not null" json:"created_at"`
	Type        string    `gorm:"not null" json:"type"`
}

Folder corresponds to a folder on disk.

func NewFolder

func NewFolder() *Folder

NewFolder creates a new folder initialized with a UUID.

type User

type User struct {
	ID       int64  `gorm:"primaryKey" json:"id"`
	Email    string `gorm:"not null;uniqueIndex" json:"email"`
	Password string `gorm:"not null" json:"-"`
}

User corresponds to a user that can login to the admin page.

func (*User) Authenticate

func (u *User) Authenticate(password string) error

Authenticate compares the provided password to the one stored in the database. An error is returned if the values do not match.

func (*User) SetPassword

func (u *User) SetPassword(password string) error

SetPassword salts and hashes the user's password. It does not store the new value in the database.

Jump to

Keyboard shortcuts

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