database

package
v0.0.2-beta Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToBson

func ConvertToBson(value interface{}) (doc bson.D, err error)

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

func MongoDB

func MongoDB(ctx context.Context, url string) (*Database, error)

func (*Database) CreateUser

func (database *Database) CreateUser(user *User) (err error)

func (*Database) GetUserById

func (database *Database) GetUserById(id string) (user User, err error)

func (*Database) GetUserByUsername

func (database *Database) GetUserByUsername(username string) (user User, err error)

func (*Database) Login

func (database *Database) Login(username, password string) (token string, err error)

func (*Database) ObjectID

func (database *Database) ObjectID(id string) primitive.ObjectID

func (*Database) Register

func (database *Database) Register(username, email, password string) bool

func (*Database) UpdateUser

func (database *Database) UpdateUser(id string, user User) (err error)

type User

type User struct {
	Id        primitive.ObjectID `bson:"_id,omitempty"`
	Firstname string             `bson:"firstname,omitempty"`
	Lastname  string             `bson:"lastname,omitempty"`
	Username  string             `bson:"username,omitempty"`
	Email     string             `bson:"email,omitempty"`
	Password  string             `bson:"password,omitempty"`
	Valid     bool               `bson:"valid,omitempty"`
}

func ConvertFromBson

func ConvertFromBson(value bson.M) (result User, err error)

Jump to

Keyboard shortcuts

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