database

package
v0.0.0-...-2bbbb8e Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorEnvVar = fmt.Errorf("missing environment variable")

ErrorEnvVar : Environment variable error

Functions

This section is empty.

Types

type MockUsers

type MockUsers struct {
}

func (*MockUsers) AddUser

func (mp *MockUsers) AddUser(ctx context.Context, user *data.User) error

AddUser creates a new user

func (*MockUsers) CloseDB

func (mp *MockUsers) CloseDB()

func (*MockUsers) Connect

func (mp *MockUsers) Connect() error

func (*MockUsers) DeleteUser

func (mp *MockUsers) DeleteUser(ctx context.Context, id string) error

DeleteUser deletes the user with the given id

func (*MockUsers) GetUserByID

func (mp *MockUsers) GetUserByID(ctx context.Context, id string) (*data.User, error)

GetUserByID returns a single user with the given id

func (*MockUsers) GetUserByUsername

func (mp *MockUsers) GetUserByUsername(ctx context.Context, username string) (*data.User, error)

GetUserByUsername returns a single user with the given id

func (*MockUsers) GetUsers

func (mp *MockUsers) GetUsers(ctx context.Context) data.Users

Return every users

func (*MockUsers) PingDB

func (mp *MockUsers) PingDB() error

func (*MockUsers) UpdateUser

func (mp *MockUsers) UpdateUser(ctx context.Context, user *data.User) error

UpdateUser updates the user specified in received JSON

type MongoUsers

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

func (*MongoUsers) AddUser

func (mp *MongoUsers) AddUser(ctx context.Context, User *data.User) error

func (*MongoUsers) CloseDB

func (mp *MongoUsers) CloseDB()

func (*MongoUsers) Connect

func (mp *MongoUsers) Connect() error

func (*MongoUsers) DeleteUser

func (mp *MongoUsers) DeleteUser(ctx context.Context, id string) error

func (*MongoUsers) GetUserByID

func (mp *MongoUsers) GetUserByID(ctx context.Context, id string) (*data.User, error)

func (*MongoUsers) GetUserByUsername

func (mp *MongoUsers) GetUserByUsername(ctx context.Context, username string) (*data.User, error)

func (*MongoUsers) GetUsers

func (mp *MongoUsers) GetUsers(ctx context.Context) data.Users

func (*MongoUsers) PingDB

func (mp *MongoUsers) PingDB() error

func (*MongoUsers) UpdateUser

func (mp *MongoUsers) UpdateUser(ctx context.Context, User *data.User) error

type UserDB

type UserDB interface {
	GetUsers(ctx context.Context) data.Users
	GetUserByID(ctx context.Context, id string) (*data.User, error)
	GetUserByUsername(ctx context.Context, username string) (*data.User, error)
	UpdateUser(ctx context.Context, user *data.User) error
	AddUser(ctx context.Context, user *data.User) error
	DeleteUser(ctx context.Context, id string) error
	Connect() error
	PingDB() error
	CloseDB()
}

The interface that any kind of database must implement

func NewMockUsers

func NewMockUsers() UserDB

func NewMongoUsers

func NewMongoUsers() UserDB

Jump to

Keyboard shortcuts

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