mongodb

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSettings

func AddSettings() (*mongo.InsertOneResult, error)

func AddUser

func AddUser(name string, email string, passwd string) (*mongo.InsertOneResult, error)

AddUser creates a new user entry in the DB. Whitespaces in the email are automatically deleted Email is a unique attribute, so the function checks for existing email, before adding a new entry

func CheckEmailAndPassword

func CheckEmailAndPassword(email string, password string) error

func Connect

func Connect() (*mongo.Client, error)

func DeleteSettings

func DeleteSettings(objID *primitive.ObjectID) (*mongo.DeleteResult, error)

func DeleteUser

func DeleteUser(email string) error

Types

type User

type User struct {
	Name       string             `json:"name,omitempty"`
	Email      string             `json:"email,omitempty"`
	Password   string             `json:"password,omitempty"`
	SettingsID primitive.ObjectID `bson:"_settings_id" json:"settings_id,omitempty"`
}

func GetUserByEmail

func GetUserByEmail(email string) (User, error)

GetUserByEmail returns the user defined by the email and password. Whitespaces in the email are automatically removed.

type UserSettings

type UserSettings struct {
	Enable2StepsVerif bool `json:"2steps_on,omitempty"`
}

func GetSettings

func GetSettings(objID *primitive.ObjectID) (UserSettings, error)

Jump to

Keyboard shortcuts

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