models

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateUser

func CreateUser(ctx context.Context, user *User) (err error)

Create a new user in the database.

Types

type Permission

type Permission struct {
	ID          int64
	Title       string
	Description sql.NullString
	Created     time.Time
	Modified    time.Time
}

type Role

type Role struct {
	ID          int64
	Title       string
	Description sql.NullString
	IsDefault   bool
	Created     time.Time
	Modified    time.Time
	// contains filtered or unexported fields
}

func GetRole

func GetRole(ctx context.Context, nameOrID any) (role *Role, err error)

Get role by ID (int64) or by title (string).

func (*Role) Permissions

func (r *Role) Permissions(ctx context.Context) (_ []*Permission, err error)

Fetch the roles permissions; if they're already cached on the role they're returned directly, otherwise the database is queried to populate the permissions.

type User

type User struct {
	ID        int64
	Name      sql.NullString
	Email     string
	Password  string
	RoleID    sql.NullInt64
	LastLogin sql.NullTime
	Created   time.Time
	Modified  time.Time
	// contains filtered or unexported fields
}

func GetUser

func GetUser(ctx context.Context, id any) (u *User, err error)

Get user by ID (int64) or by email (string).

func (*User) LoggedIn

func (u *User) LoggedIn(ctx context.Context) (err error)

func (*User) Permissions

func (u *User) Permissions(ctx context.Context) (_ []*Permission, err error)

func (*User) Role

func (u *User) Role(ctx context.Context) (_ *Role, err error)

Jump to

Keyboard shortcuts

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