user

package
v0.0.0-...-172aab7 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(filter bson.M) int

Count users

func DeleteMany

func DeleteMany(filter bson.M) error

DeleteMany user

func Drop

func Drop() error

Drop users collection

func SetIndex

func SetIndex(keys bson.M, unique bool) error

SetIndex create index

func UpdateMany

func UpdateMany(filter, update bson.M) error

UpdateMany users

Types

type User

type User struct {
	ID        primitive.ObjectID `bson:"_id" json:"id"`
	Name      string             `bson:"name" json:"name"`
	About     string             `bson:"about" json:"about"`
	Email     string             `bson:"email" json:"email"`
	Password  string             `bson:"password" json:"-"`
	SuperUser bool               `bson:"super_user" json:"super_user"`
	Thumbnail primitive.ObjectID `bson:"thumbnail" json:"thumbnail"`
	CreatedAt time.Time          `bson:"created_at" json:"created_at"`
}

User model

func AuthByEmail

func AuthByEmail(email, password string) (*User, error)

AuthByEmail authenticate with email

func Find

func Find(filter bson.M, page, limit int, sorts ...bson.E) (users []User)

Find users

func FindOne

func FindOne(filter bson.M) (*User, error)

FindOne user

func LoadByEmail

func LoadByEmail(email string) (*User, error)

LoadByEmail load by email

func LoadByRequest

func LoadByRequest(req *http.Request) (*User, error)

LoadByRequest load user from reqeust

func (*User) Delete

func (u *User) Delete() error

DeleteOne a user

func (*User) Insert

func (u *User) Insert() error

Insert new user

func (*User) Save

func (u *User) Save() error

Save a user insert or update

func (*User) UpdateOne

func (u *User) UpdateOne() error

UpdateOne a user

Jump to

Keyboard shortcuts

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