mongodb

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

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

Go to latest
Published: Sep 10, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collections

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

Collections represents all needed db collections

type Config

type Config struct {
	ConnectionURI string `yaml:"connection_uri"`
	DatabaseName  string `yaml:"database_name"`
}

Config represents MongoDB configuration

type DB

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

DB represents the structure of the database

func NewConnection

func NewConnection(config *Config) (*DB, error)

NewConnection creates a new database connection

func (*DB) CloseConnection

func (db *DB) CloseConnection() error

CloseConnection closes the database connection

func (*DB) CreateUser

func (db *DB) CreateUser(u *model.User) error

CreateUser creates a new user

func (*DB) DeleteUser

func (db *DB) DeleteUser(id string) error

DeleteUser deletes the user with the given id

func (*DB) GetUser

func (db *DB) GetUser(id string) (*model.User, error)

GetUser returns a user

func (*DB) GetUserByEmail

func (db *DB) GetUserByEmail(email string) (*model.User, error)

GetUserByEmail returns a user by his email address

func (*DB) SaveUser

func (db *DB) SaveUser(u *model.User) error

SaveUser saves the given user struct

Jump to

Keyboard shortcuts

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