dao

package
v0.0.0-...-3d8588d Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const AnimalCollection = "animals"

AnimalCollection collection name

View Source
const ArticleCollection = "articles"

ArticleCollection collection name

View Source
const ImageCollection = "images"

ImageCollection collection name

View Source
const PageCollection = "pages"

PageCollection collection name

View Source
const PasswordTokenAuthCollection = "usersPasswordTokenAuth"

PasswordTokenAuthCollection is the collection used for user password storage

View Source
const UserCollection = "users"

UserCollection collection name

Variables

This section is empty.

Functions

This section is empty.

Types

type DAO

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

DAO allow easy acces to database

func New

func New(ctx context.Context) *DAO

New return a new data acces object

func (*DAO) CountImages

func (d *DAO) CountImages(ctx context.Context, filterInput ListImageFilter) (int64, error)

CountImages count images with provided filters

func (*DAO) CreateAnimal

func (d *DAO) CreateAnimal(ctx context.Context, in model.Animal) (*model.Animal, error)

CreateAnimal create a new animal

func (*DAO) CreateArticle

func (d *DAO) CreateArticle(ctx context.Context, in model.Article) (*model.Article, error)

CreateArticle add a article to DB

func (*DAO) CreateImage

func (d *DAO) CreateImage(ctx context.Context, in model.Image) (*model.Image, error)

CreateImage add a image to DB

func (*DAO) CreatePage

func (d *DAO) CreatePage(ctx context.Context, in model.Page) (*model.Page, error)

CreatePage add a page to DB

func (*DAO) CreatePasswordToken

func (d *DAO) CreatePasswordToken(ctx context.Context, token model.PasswordRenewalToken) (*model.PasswordRenewalToken, error)

CreatePasswordToken create a new password renewal token

func (*DAO) DeleteImage

func (d *DAO) DeleteImage(ctx context.Context, id primitive.ObjectID) error

DeleteImage delete an image to DB

func (*DAO) DeletePage

func (d *DAO) DeletePage(ctx context.Context, id primitive.ObjectID) error

DeletePage delete a page to DB

func (*DAO) DeletePasswordToken

func (d *DAO) DeletePasswordToken(ctx context.Context, id primitive.ObjectID) error

DeletePasswordToken delete a password renewal token

func (*DAO) GetAnimalByID

func (d *DAO) GetAnimalByID(ctx context.Context, id primitive.ObjectID) (*model.Animal, error)

GetAnimalByID get animal by id

func (*DAO) GetArticleByID

func (d *DAO) GetArticleByID(ctx context.Context, id primitive.ObjectID) (*model.Article, error)

GetArticleByID get article by id

func (*DAO) GetImageByID

func (d *DAO) GetImageByID(ctx context.Context, id primitive.ObjectID) (*model.Image, error)

GetImageByID get image by id

func (*DAO) GetPageByID

func (d *DAO) GetPageByID(ctx context.Context, id primitive.ObjectID) (*model.Page, error)

GetPageByID get page by id

func (*DAO) GetPasswordTokenByValue

func (d *DAO) GetPasswordTokenByValue(ctx context.Context, token string) (*model.PasswordRenewalToken, error)

GetPasswordTokenByValue get a password renewal token by its value

func (*DAO) GetUserByEmail

func (d *DAO) GetUserByEmail(ctx context.Context, email string) (*model.User, error)

GetUserByEmail get user by email

func (*DAO) GetUserByID

func (d *DAO) GetUserByID(ctx context.Context, id primitive.ObjectID) (*model.User, error)

GetUserByID get user by id

func (*DAO) GetUserByName

func (d *DAO) GetUserByName(ctx context.Context, username string) (*model.User, error)

GetUserByName get user by name

func (*DAO) ListAnimals

func (d *DAO) ListAnimals(ctx context.Context, filter ListAnimalsFilter, pagination paging.StdPaging) ([]model.Animal, error)

ListAnimals list animals

func (*DAO) ListArticles

func (d *DAO) ListArticles(ctx context.Context, filter ListArticlesFilter, pagination paging.StdPaging) ([]model.Article, error)

ListArticles list articles

func (*DAO) ListImages

func (d *DAO) ListImages(ctx context.Context, f ListImageFilter, pagination paging.StdPaging) ([]model.Image, error)

ListImages list images

func (*DAO) ListPages

func (d *DAO) ListPages(ctx context.Context, filter ListPagesFilter, pagination paging.StdPaging) ([]model.Page, error)

ListPages list pages

func (*DAO) UpdateAnimal

func (d *DAO) UpdateAnimal(ctx context.Context, id primitive.ObjectID, in model.Animal) (*model.Animal, error)

UpdateAnimal update an animal to DB

func (*DAO) UpdateArticle

func (d *DAO) UpdateArticle(ctx context.Context, id primitive.ObjectID, in model.Article) (*model.Article, error)

UpdateArticle update an article to DB

func (*DAO) UpdatePage

func (d *DAO) UpdatePage(ctx context.Context, id primitive.ObjectID, in model.Page) (*model.Page, error)

UpdatePage update a page to DB

func (*DAO) UpdateUser

func (d *DAO) UpdateUser(ctx context.Context, id primitive.ObjectID, in model.User) (*model.User, error)

UpdateUser update a user to DB

type ListAnimalsFilter

type ListAnimalsFilter struct {
	Name           *string               `mgo-filter:"name,op:$eq,omitempty"`
	Description    *string               `mgo-filter:"description,op:$eq,omitempty"`
	Birthdate      *time.Time            `mgo-filter:"birthdate,op:$eq,omitempty"`
	Sex            *model.Sex            `mgo-filter:"sex,op:$eq,omitempty"`
	Color          *string               `mgo-filter:"color,op:$eq,omitempty"`
	AdoptionStatus *model.AdoptionStatus `mgo-filter:"adoptionstatus,op:$eq,omitempty"`
	RawFilter      bson.M                `mgo-filter-raw:"-"`
}

ListAnimalsFilter contains filtering tools

type ListArticlesFilter

type ListArticlesFilter struct {
	Name      *string `mgo-filter:"name,op:$eq,omitempty"`
	RawFilter bson.M  `mgo-filter-raw:"-"`
}

ListArticlesFilter contains filtering tools

type ListImageFilter

type ListImageFilter struct {
	Name      *string             `mgo-filter:"name,op:$eq,omitempty"`
	ID        *primitive.ObjectID `mgo-filter:"_id,op:$eq,omitempty"`
	RawFilter bson.M              `mgo-filter-raw:"-"`
}

ListImageFilter contains filtering tools

type ListPagesFilter

type ListPagesFilter struct {
	Name *string `mgo-filter:"name,op:$eq,omitempty"`
}

ListPagesFilter contains filtering tools

Jump to

Keyboard shortcuts

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