manager

package
v0.0.0-...-89f3358 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category struct {
	ID       bson.ObjectId   `json:"id" bson:"_id,omitempty"`
	UserID   bson.ObjectId   `json:"userId" bson:"userId"`
	Name     string          `json:"name"`
	ImageIDs []bson.ObjectId `json:"imageIds" bson:"imageIds"`
}

Category entity. A category may contain multiple images and an image can belong to multiple categories.

func NewCategory

func NewCategory(catID ...string) *Category

NewCategory returns a new category.

func (*Category) AddImage

func (cat *Category) AddImage(db *mgo.Database, u *User, img *Image)

func (*Category) CreateCategory

func (cat *Category) CreateCategory(db *mgo.Database, user *User)

CreateCategory inserts a category.

func (*Category) DeleteCategory

func (cat *Category) DeleteCategory(db *mgo.Database, user *User) (found bool)

DeleteCategory deletes a category.

func (*Category) HasImage

func (cat *Category) HasImage(db *mgo.Database, img *Image) bool

func (*Category) ReadCategory

func (cat *Category) ReadCategory(db *mgo.Database, user *User) (found bool)

ReadCategory fetches a category.

func (*Category) RemoveImage

func (cat *Category) RemoveImage(db *mgo.Database, u *User, img *Image)

func (*Category) UpdateCategory

func (cat *Category) UpdateCategory(db *mgo.Database, user *User) (found bool)

UpdateCategory updates a category.

type Image

type Image struct {
	ID      bson.ObjectId `json:"id" bson:"_id,omitempty"`
	UserID  bson.ObjectId `json:"userId" bson:"userId"`
	ImageID string        `json:"imageId" bson:"imageId"`
}

func NewImage

func NewImage(imgID ...string) *Image

NewImage returns a new image.

func (*Image) CreateImage

func (img *Image) CreateImage(db *mgo.Database, user *User)

func (*Image) ReadImage

func (img *Image) ReadImage(db *mgo.Database, user *User) (found bool)

func (*Image) ReadImageByID

func (img *Image) ReadImageByID(db *mgo.Database) (found bool)

type QueryOptions

type QueryOptions struct {
	Skip  int
	Limit int
	Sort  []string
}

QueryOptions options.

type User

type User struct {
	ID          bson.ObjectId `json:"id" bson:"_id,omitempty"`
	AccessToken string        `json:"accessToken" bson:"accessToken"`
	AccountID   string        `json:"accountId" bson:"accountId"`
}

User entity. The AccessToken and AccountID properties are provided by the user's Dropbox account.

func NewUser

func NewUser(userID ...string) *User

NewUser creates a user.

func (*User) CreateUser

func (user *User) CreateUser(db *mgo.Database)

CreateUser creates a user.

func (*User) GetCategories

func (user *User) GetCategories(db *mgo.Database, options QueryOptions, parentCatID string) []Category

GetCategories returns a list of categories..

func (*User) GetNumCategories

func (user *User) GetNumCategories(db *mgo.Database, options QueryOptions, parentCatID string) int

GetNumCategories returns the number of categories.

func (*User) ReadUserByAccountID

func (user *User) ReadUserByAccountID(db *mgo.Database) (found bool)

ReadUserByAccountID searches a user by account ID.

func (*User) ReadUserByToken

func (user *User) ReadUserByToken(db *mgo.Database) (found bool)

ReadUserByToken searches a user by access token.

func (*User) UpdateUser

func (user *User) UpdateUser(db *mgo.Database) (found bool)

UpdateUser updates a user.

Jump to

Keyboard shortcuts

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