utilmongo

package
v0.0.0-...-70b0572 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MONGO_DB_URL      = "MONGO_DB_URL"
	MONGO_DB_USERNAME = "MONGO_USERNAME"
	MONGO_DB_PASSWORD = "MONGO_PASSWORD"
	MONGO_DB_NAME     = "MONGO_DB_NAME"
)

Variables

View Source
var (
	AccessDB string = "access"
)

Functions

func MongoDBLogin

func MongoDBLogin() (*mgo.Database, error)

Types

type Pagination

type Pagination struct {
	HasNext  bool        `json:"has_next"`
	HasPrev  bool        `json:"has_prev"`
	PerPage  int         `json:"perpage"`
	Page     int         `json:"page"`
	LastPage int         `json:"last_page"`
	Total    int         `json:"total"`
	Items    interface{} `json:"items"`
}

Pagination represents a paging

func Paginate

func Paginate(db *mgo.Database, col string, query, fields bson.M, result interface{}, page, perPage int, sorts []string) (*Pagination, error)

Paginate do paginate query

func PipelinePaginate

func PipelinePaginate(c *mgo.Collection, operations []bson.M, result interface{}, page, perPage, total int) (*Pagination, error)

Pipeline paginate implement paginate in with pipeline operations

Jump to

Keyboard shortcuts

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