user

package
v0.0.0-...-1e64615 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHandler

func RegisterHandler(w http.ResponseWriter, r *http.Request)

Types

type DbHandler

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

DbHandler represents a handler for interacting with the MongoDB database.

func NewDbHandler

func NewDbHandler(db *mongo.Database) *DbHandler

NewDbHandler creates a new DbHandler instance with the provided MongoDB database connection.

func (*DbHandler) CreateUser

func (h *DbHandler) CreateUser(user User) error

CreateUser function adds a user to the database It checks to see if user already exist if user exist it returns an error

func (*DbHandler) GetUserByEmail

func (h *DbHandler) GetUserByEmail(Email string) (*User, error)

GetUserByEmail retrives the user from the database based on the Email provided

func (*DbHandler) GetUserById

func (h *DbHandler) GetUserById(Id string) (*User, error)

GetUserById retrives the user info from the databse using Id provided

func (*DbHandler) GetUserByUsername

func (h *DbHandler) GetUserByUsername(Username string) (*User, error)

type User

type User struct {
	ID       string `bson:"_id"`
	Username string `bson:"username"`
	Email    string `bson:"email"`
	Password string `bson:"password"`
}

Jump to

Keyboard shortcuts

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