database

package
v0.0.0-...-ff79fe2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

Types

type Database

type Database struct {
	DB     *gorm.DB
	Logger zerolog.Logger
}

func (*Database) CreateUser

func (c *Database) CreateUser(user *api.User) (*api.User, error)

func (*Database) DeleteUser

func (c *Database) DeleteUser(id int64, hardDelete bool) error

func (*Database) GetUserByID

func (c *Database) GetUserByID(id int64) (*api.User, error)

func (*Database) GetUserByUsername

func (c *Database) GetUserByUsername(username string) (*api.User, error)

func (*Database) ListUsers

func (c *Database) ListUsers(filters *ListFilters) ([]*api.User, error)

func (*Database) UpdateUser

func (c *Database) UpdateUser(id int64, newData *api.User) error

type ListFilters

type ListFilters struct {
	Page       *int
	UsernameIn []string
	EmailIn    []string
	IDIn       []int64
}

type User

type User struct {
	ID           int64     `gorm:"primarykey;<-:create"`
	CreatedAt    time.Time `gorm:"<-:create"`
	UpdatedAt    time.Time
	DeletedAt    gorm.DeletedAt `gorm:"index"`
	PasswordHash []byte
	// TODO: salt must become readonly
	Salt           []byte
	Username       string         `gorm:"unique;size:100"`
	DisplayName    string         `gorm:"size:100"`
	Email          string         `gorm:"unique;size:300"`
	RegistrationIP string         `gorm:"size:50;<-:create"`
	Bio            sql.NullString `gorm:"unique;size:500"`
	Birthday       sql.NullTime   `json:"birthday,omitempty" yaml:"birthday,omitempty"`
}

func (User) TableName

func (User) TableName() string

func (*User) ToApiUser

func (u *User) ToApiUser() *api.User

Jump to

Keyboard shortcuts

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