models

package
v0.0.0-...-5c919d2 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 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 Clothes

type Clothes struct {
	ID        primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"`
	Owner     primitive.ObjectID `json:"owner,omitempty" bson:"owner,omitempty"`
	ImageURL  string             `json:"image_url,omitempty" bson:"image_url,omitempty"`
	Color     string             `json:"color,omitempty" bson:"color,omitempty"`
	ClothType string             `json:"type,omitempty" bson:"type,omitempty"`
}

Clothes represents a clothing item on the system

type ClothesStore

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

ClothesStore contains all the CRUD operations for the Clothes model

func NewClothesStore

func NewClothesStore(database *mongo.Database) *ClothesStore

NewClothesStore creates a new ClothesStore with a given database

func (*ClothesStore) Create

func (cs *ClothesStore) Create(c Clothes, userID string) (Clothes, error)

Create stores new clothes on the database for a user id

func (*ClothesStore) GetAll

func (cs *ClothesStore) GetAll(userID string, filteredBy string) ([]Clothes, error)

GetAll retrieves all clothes from the database for a given user

func (*ClothesStore) GetByID

func (cs *ClothesStore) GetByID(id string, userID string) (Clothes, error)

GetByID retrieves a clothes object from the database with a given id and owner id

type User

type User struct {
	ID       primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"`
	Name     string             `json:"name,omitempty" bson:"name,omitempty"`
	Lastname string             `json:"lastname,omitempty" bson:"lastname,omitempty"`
	Email    string             `json:"email,omitempty" bson:"email,omitempty"`
	Password string             `json:"password,omitempty" bson:"password,omitempty"`
	Status   string             `json:"status,omitempty" bson:"status,omitempty"`
}

User model represents a user on the system

type UserStore

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

UserStore contains all the CRUD operations for the User model

func NewUserStore

func NewUserStore(database *mongo.Database) *UserStore

NewUserStore creates a user store with a mongo database

func (*UserStore) Create

func (us *UserStore) Create(u User) (User, error)

Create stores a new user in the users collection

func (*UserStore) GetByEmail

func (us *UserStore) GetByEmail(email string) (User, error)

GetByEmail retrieves a user by a given email

func (*UserStore) GetByID

func (us *UserStore) GetByID(id string) (User, error)

GetByID gets a user with a given id from the database

func (*UserStore) ValidEmail

func (us *UserStore) ValidEmail(email string) bool

ValidEmail hecks if an email is already taken

Jump to

Keyboard shortcuts

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