Documentation
¶
Index ¶
Constants ¶
View Source
const ( PageLimitError = "page or limit cannot be less than 0" DecodeEmptyError = "struct should be provide to decode data" DecodeNotAvail = "this feature is not available for aggregate query" FilterInAggregateError = "you cannot use filter in aggregate query but you can pass multiple filter as param in aggregate function" NilFilterError = "filter query cannot be nil" )
Error constants
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AutoGenerated ¶
type AutoGenerated struct {
Total []struct {
Count int64 `json:"count"`
} `json:"total"`
Data []bson.Raw `json:"data"`
}
AutoGenerated is to bind Aggregate query result data
type PaginatedData ¶
type PaginatedData struct {
Data []bson.Raw `json:"data"`
Pagination PaginationData `json:"pagination"`
}
PaginatedData struct holds data and pagination detail
type PaginationData ¶
type PaginationData struct {
Total int64 `json:"total"`
Page int64 `json:"page"`
PerPage int64 `json:"perPage"`
Prev int64 `json:"prev"`
Next int64 `json:"next"`
TotalPage int64 `json:"totalPage"`
}
PaginationData struct for returning pagination stat
type Paginator ¶
type Paginator struct {
TotalRecord int64 `json:"total_record"`
TotalPage int64 `json:"total_page"`
Offset int64 `json:"offset"`
Limit int64 `json:"limit"`
Page int64 `json:"page"`
PrevPage int64 `json:"prev_page"`
NextPage int64 `json:"next_page"`
}
Paginator struct for holding pagination info
func (*Paginator) PaginationData ¶
func (p *Paginator) PaginationData() *PaginationData
PaginationData returns PaginationData struct which holds information of all stats needed for pagination
type PagingQuery ¶
type PagingQuery interface {
// Find set the filter for query results.
Find() (paginatedData *PaginatedData, err error)
Aggregate(criteria ...interface{}) (paginatedData *PaginatedData, err error)
// Select used to enable fields which should be retrieved.
Select(selector interface{}) PagingQuery
Filter(selector interface{}) PagingQuery
Limit(limit int64) PagingQuery
Page(page int64) PagingQuery
Sort(sortField string, sortValue interface{}) PagingQuery
Decode(decode interface{}) PagingQuery
Context(ctx context.Context) PagingQuery
SetCollation(ctx *options.Collation) PagingQuery
}
PagingQuery is an interface that provides list of function you can perform on pagingQuery
func New ¶
func New(collection *mongo.Collection) PagingQuery
New is to construct PagingQuery object with mongo.Database and collection name
Click to show internal directories.
Click to hide internal directories.
