models

package
v1.6.8 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SIGNAL_BEFORE_USER_CREATE = user_signal_pool.Get("user.before_create") // -> Send(auth.User) (Returned error unused!)
	SIGNAL_AFTER_USER_CREATE  = user_signal_pool.Get("user.after_create")  // -> Send(auth.User) (Returned error unused!)

	SIGNAL_BEFORE_USER_UPDATE = user_signal_pool.Get("user.before_update") // -> Send(auth.User) (Returned error unused!)
	SIGNAL_AFTER_USER_UPDATE  = user_signal_pool.Get("user.after_update")  // -> Send(auth.User) (Returned error unused!)

	SIGNAL_BEFORE_USER_DELETE = id_signal_pool.Get("user.before_delete") // -> Send(int64) (Returned error unused!)
	SIGNAL_AFTER_USER_DELETE  = id_signal_pool.Get("user.after_delete")  // -> Send(int64) (Returned error unused!)

)
View Source
var BackendForDB = backend.BackendForDB
View Source
var Register = backend.RegisterForDriver

Functions

func CreateUser

func CreateUser(ctx context.Context, u *User) (int64, error)

func DeleteUser

func DeleteUser(ctx context.Context, u *User) error

func UpdateUser

func UpdateUser(ctx context.Context, u *User) error

Types

type DBQuerier

type DBQuerier interface {
	Querier
	DB() *sql.DB
	BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
}

func NewQueries

func NewQueries(db *sql.DB) (DBQuerier, error)

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Email

type Email mail.Address

func (*Email) Scan

func (e *Email) Scan(src interface{}) error

func (*Email) ScanAttribute

func (e *Email) ScanAttribute(src interface{}) error

func (Email) String

func (e Email) String() string

func (Email) Value

func (e Email) Value() (driver.Value, error)

type Password

type Password string

type Querier

type Querier interface {
	Count(ctx context.Context) (int64, error)
	CountMany(ctx context.Context, isActive bool, isAdministrator bool) (int64, error)
	CreateUser(ctx context.Context, email string, username string, password string, firstName string, lastName string, isAdministrator bool, isActive bool) (int64, error)
	DeleteUser(ctx context.Context, id uint64) error
	Retrieve(ctx context.Context, limit int32, offset int32) ([]*User, error)
	RetrieveByEmail(ctx context.Context, email string) (*User, error)
	RetrieveByID(ctx context.Context, id uint64) (*User, error)
	RetrieveByUsername(ctx context.Context, username string) (*User, error)
	RetrieveMany(ctx context.Context, isActive bool, isAdministrator bool, limit int32, offset int32) ([]*User, error)
	UpdateUser(ctx context.Context, email string, username string, password string, firstName string, lastName string, isAdministrator bool, isActive bool, iD uint64) error
	WithTx(tx *sql.Tx) Querier
	Close() error
}

type User

type User struct {
	ID              uint64    `json:"id" attrs:"primary;readonly"`
	CreatedAt       time.Time `json:"created_at" attrs:"readonly"`
	UpdatedAt       time.Time `json:"updated_at" attrs:"readonly"`
	Email           *Email    `json:"email"`
	Username        string    `json:"username"`
	Password        Password  `json:"password"`
	FirstName       string    `json:"first_name"`
	LastName        string    `json:"last_name"`
	IsAdministrator bool      `json:"is_administrator" attrs:"blank;default=true"`
	IsActive        bool      `json:"is_active" attrs:"blank;default=true"`
	IsLoggedIn      bool      `json:"is_logged_in"`
}

func (*User) Delete

func (u *User) Delete(ctx context.Context) error

func (*User) FieldDefs

func (u *User) FieldDefs() attrs.Definitions

func (*User) IsAdmin

func (u *User) IsAdmin() bool

func (*User) IsAuthenticated

func (u *User) IsAuthenticated() bool

func (*User) Reload

func (u *User) Reload(ctx context.Context) error

func (*User) Save

func (u *User) Save(ctx context.Context) error

func (*User) String added in v1.6.8

func (u *User) String() string

func (*User) Update

func (u *User) Update(ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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