mongo

package module
v0.0.0-...-7ed76d0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdventCalendarDay

type AdventCalendarDay struct {
	ID      primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	Day     uint8              `bson:"day" json:"day" binding:"required" validate:"required,min=1,max=31"`
	Year    uint16             `bson:"year" json:"year" binding:"required" validate:"required,min=1900,max=9999"`
	Title   string             `bson:"title" json:"title" binding:"required" validate:"required,min=1,max=255"`
	Content string             `bson:"content" json:"content" binding:"required" validate:"required,min=1,max=65555"`
}

type AdventCalendarDayUpdate

type AdventCalendarDayUpdate struct {
	ID      primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	Day     uint8              `bson:"day" json:"day"`
	Year    uint16             `bson:"year" json:"year"`
	Title   string             `bson:"title" json:"title"`
	Content string             `bson:"content" json:"content"`
}

type DayIDRequest

type DayIDRequest struct {
	Id primitive.ObjectID `bson:"_id,omitempty" json:"id" binding:"required" validate:"required"`
}

type Repository

type Repository struct {
	Db  *mongo.Client
	Ctx *context.Context
}

func NewRepository

func NewRepository(client *mongo.Client, ctx *context.Context) *Repository

Public functions

func (*Repository) Connect

func (r *Repository) Connect(username string, password string, address string, port int) (*mongo.Client, *context.Context, error)

func (*Repository) CreateDay

func (r *Repository) CreateDay(day *AdventCalendarDay, dbName, collectionName string) error

func (*Repository) CreateDb

func (r *Repository) CreateDb(dbName, collectionName string) error

func (*Repository) DeleteDay

func (r *Repository) DeleteDay(day *DayIDRequest, dbName, collectionName string) error

func (*Repository) Disconnect

func (r *Repository) Disconnect()

func (*Repository) GetAllDatabase

func (r *Repository) GetAllDatabase() ([]string, error)

func (*Repository) GetAllDay

func (r *Repository) GetAllDay(dbName, collectionName string) ([]*AdventCalendarDay, error)

func (*Repository) GetDay

func (r *Repository) GetDay(day uint8, dbName, collectionName string) (*AdventCalendarDay, error)

func (*Repository) PingDb

func (r *Repository) PingDb() error

func (*Repository) UpdateDay

func (r *Repository) UpdateDay(day *AdventCalendarDayUpdate, dbName, collectionName string) error

Jump to

Keyboard shortcuts

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