mongo

package
v1.5.61 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Unlicense Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	ID        primitive.ObjectID `bson:"_id" json:"id" form:"id"`
	CreatedAt int64              `bson:"created_at" json:"created_at" form:"created_at"`
	UpdatedAt int64              `bson:"updated_at" json:"updated_at" form:"updated_at"`

	//Pagination and Filter
	Pagination Pagination `json:"-" form:"-" bson:"-"`
	//Practice
	IsTest bool `json:"-" form:"tutorial" bson:"-"`
}

Model of Collection

func (*Model) Bind

func (m *Model) Bind(ctx *gin.Context, data interface{}) (err error)

func (*Model) Create

func (this *Model) Create(mdl interface{}) (err error)

func (*Model) Delete added in v1.5.4

func (this *Model) Delete(data interface{}, filter bson.M, opts ...*options.DeleteOptions) (err error)

func (*Model) Get added in v1.5.0

func (this *Model) Get(data interface{}, filter bson.M, opts ...*options.FindOptions) (err error)

func (*Model) Update added in v1.5.4

func (this *Model) Update(data interface{}, filter bson.M, opts ...*options.UpdateOptions) (err error)

type Mongo

type Mongo struct {
	Config databases.Config
}

Connection

func (*Mongo) Connect

func (mdb *Mongo) Connect() (Db *mongo.Database, client *mongo.Client, err error)

type Pagination

type Pagination struct {
	//Search
	Keyword   string `json:"-" form:"keyword"`
	StartDate int64  `json:"-" form:"start_date"`
	EndDate   int64  `json:"-" form:"end_date"`
	Sort      string `json:"-" form:"sort"`
	SortBy    string `json:"-" form:"sort_by"`

	//Pagination
	ShowAll   bool  `json:"-" form:"show_all"`
	Page      int64 `json:"current_page" form:"page"`
	PageSize  int64 `json:"page_size" form:"page_size"`
	TotalPage int64 `json:"page_total"`
	TotalData int64 `json:"data_total"`
	HasNext   bool  `json:"has_next"`
	HasPrev   bool  `json:"has_previous"`
}

Jump to

Keyboard shortcuts

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