user

package
v0.0.0-...-0cfb223 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Collection = "users"

Collection indicates the MongoDB user collection

Variables

View Source
var (
	// ErrInvalidEmail indicates that a email address is not valid
	ErrInvalidEmail = errors.New("invalid e-mail address")
)

Functions

func Create

func Create(user *User) error

Create creates a new entity

func GetAll

func GetAll(opts *Options) (*model.Result, error)

GetAll returns a result based on filters

func GetByEmail

func GetByEmail(addr string, opts *Options) (*model.Result, error)

GetByEmail returns a result based on email address

func GetByLockedState

func GetByLockedState(locked bool, opts *Options) (*model.Result, error)

GetByLockedState returns a result based on lock state

func Remove

func Remove(id string) error

Remove removes an entity

func Replace

func Replace(id string, user *User) error

Replace replaces the data of an existing entity

Types

type Options

type Options struct {
	Sort   bson.D
	Limit  int64
	Offset int64
}

Options represents the options for a database operation

type User

type User struct {
	ID       objectID  `json:"_id" bson:"_id"`
	Email    string    `json:"email" bson:"email"`
	Locked   bool      `json:"locked" bson:"locked"`
	Modified timestamp `json:"_modified" bson:"_modified"`
}

User describes the entity of a user

func GetByID

func GetByID(id string) (*User, error)

GetByID returns the entity of the given ID

func (*User) Validate

func (u *User) Validate() error

Validate validates the fields of a user

Jump to

Keyboard shortcuts

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