types

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UserCollection db collection name
	UserCollection = "user"
)

Variables

View Source
var (
	// ErrUserExists returned if user with same name exists
	ErrUserExists = errors.New("user with same name or email exists")
	// ErrUserNotFound is returned if user is not found
	ErrUserNotFound = errors.New("user not found")
	// ErrBadUserUpdate is returned when invalid data is passed to update
	ErrBadUserUpdate = errors.New("bad data during user update")
	// ErrAuthorization returned if user is not allowed to do an operation
	ErrAuthorization = errors.New("operation not allowed")
)

Functions

func Setup

func Setup(ctx context.Context, db *mongo.Database) error

Setup sets up indexes for types, must be called at least Onetime during the life time of the object

func UserUpdate

func UserUpdate(ctx context.Context, db *mongo.Database, id schema.ID, signature []byte, update User) error

UserUpdate update user info

Types

type User

type User generated.User

User type

func UserCreate

func UserCreate(ctx context.Context, db *mongo.Database, name, email, pubkey string) (user User, err error)

UserCreate creates the user

func (*User) Encode

func (u *User) Encode() []byte

Encode user data for signing

func (User) Validate

func (u User) Validate() error

Validate makes the sanity check requires for the user type

type UserFilter

type UserFilter bson.D

UserFilter type

func (UserFilter) Count

func (f UserFilter) Count(ctx context.Context, db *mongo.Database) (int64, error)

Count number of documents matching

func (UserFilter) Find

func (f UserFilter) Find(ctx context.Context, db *mongo.Database, opts ...*options.FindOptions) (*mongo.Cursor, error)

Find all users that matches filter

func (UserFilter) Get

func (f UserFilter) Get(ctx context.Context, db *mongo.Database) (user User, err error)

Get single user

func (UserFilter) WithEmail

func (f UserFilter) WithEmail(email string) UserFilter

WithEmail filters user with email

func (UserFilter) WithID

func (f UserFilter) WithID(id schema.ID) UserFilter

WithID filters user with ID

func (UserFilter) WithName

func (f UserFilter) WithName(name string) UserFilter

WithName filters user with name

Jump to

Keyboard shortcuts

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