user

package
v0.0.0-...-f12052e Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Collection = "users"

Collection is a name of the MongoDB collection for Users.

Variables

View Source
var (
	// ErrEmailNotFound indicates that given email does not exist on database.
	ErrEmailNotFound = errors.New("given email does not exist")
	// ErrEmailDuplicate indicates that given email is exists on database.
	ErrEmailDuplicate = errors.New("given email exists")
)

Functions

This section is empty.

Types

type MemoryUser

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

func NewMemoryUser

func NewMemoryUser() *MemoryUser

func (MemoryUser) Get

func (m MemoryUser) Get(_ context.Context, email string) (model.User, error)

func (MemoryUser) Set

func (m MemoryUser) Set(_ context.Context, user model.User) error

type MongoUser

type MongoUser struct {
	DB     *mongo.Database
	Tracer trace.Tracer
}

MongoURL communicate with users collection in MongoDB.

func NewMongoUser

func NewMongoUser(db *mongo.Database, tracer trace.Tracer) *MongoUser

NewMongoUser creates new User store.

func (*MongoUser) Get

func (s *MongoUser) Get(ctx context.Context, email string) (model.User, error)

Get retrieves user of the given email if it exists.

func (*MongoUser) Set

func (s *MongoUser) Set(ctx context.Context, user model.User) error

Set saves given user in database.

type User

type User interface {
	Set(ctx context.Context, user model.User) error
	Get(ctx context.Context, email string) (model.User, error)
}

User stores and retrieves users.

Jump to

Keyboard shortcuts

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