Skip to content

Commit

Permalink
Updated results mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Cataldo committed Jan 12, 2024
1 parent 3629b12 commit 0d09d73
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 56 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ MongoDB Template
<!--suppress ALL -->
<img align="right" src="gopher-mongo.png" alt="">

[![Project status](https://img.shields.io/badge/version-v1.0.1-vividgreen.svg)](https://github.com/GabrielHCataldo/go-mongo-template/releases/tag/v1.0.1)
[![Project status](https://img.shields.io/badge/version-v1.0.2-vividgreen.svg)](https://github.com/GabrielHCataldo/go-mongo-template/releases/tag/v1.0.2)
[![Go Report Card](https://goreportcard.com/badge/github.com/GabrielHCataldo/go-mongo-template)](https://goreportcard.com/report/github.com/GabrielHCataldo/go-mongo-template)
[![Coverage Status](https://coveralls.io/repos/GabrielHCataldo/go-mongo-template/badge.svg?branch=main&service=github)](https://coveralls.io/github/GabrielHCataldo/go-mongo?branch=main)
[![Open Source Helpers](https://www.codetriage.com/gabrielhcataldo/go-mongo-template/badges/users.svg)](https://www.codetriage.com/gabrielhcataldo/go-mongo)
Expand Down
2 changes: 1 addition & 1 deletion mongo/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type IndexInput struct {
Ref any
}

type IndexOutput struct {
type IndexResult struct {
Id any `bson:"id,omitempty"`
Ns string `bson:"ns,omitempty"`
FirstBatch FirstBatchIndex `bson:"firstBatch,omitempty"`
Expand Down
6 changes: 3 additions & 3 deletions mongo/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type PageInput struct {
Sort any
}

type PageOutput struct {
type PageResult struct {
Page int64 `json:"page"`
PageSize int64 `json:"pageSize"`
PageTotal int64 `json:"pageTotal"`
Expand All @@ -22,14 +22,14 @@ type PageOutput struct {
LastQueryAt time.Time `json:"lastQueryAt,omitempty"`
}

func NewPageOutput(pageInput PageInput, result any, countTotal int64) *PageOutput {
func newPageResult(pageInput PageInput, result any, countTotal int64) *PageResult {
minPageTotal := 1
if util.IsZero(result) {
minPageTotal = 0
}
pageTotal := util.MinInt64(int64(math.Ceil(float64(countTotal)/float64(pageInput.PageSize))), int64(minPageTotal))
lastQueryAt := time.Now().UTC()
return &PageOutput{
return &PageResult{
Page: pageInput.Page,
PageSize: pageInput.PageSize,
PageTotal: pageTotal,
Expand Down
Loading

0 comments on commit 0d09d73

Please sign in to comment.