From d65785d690953a1f3bb45dd71aa7e645af2d6899 Mon Sep 17 00:00:00 2001 From: Gabriel Cataldo Date: Mon, 4 Mar 2024 07:32:21 -0300 Subject: [PATCH] Bug fix next page on findPageable func --- README.md | 2 +- mongo/template.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a9ddbcb..a216ab9 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ MongoDB Template -[![Project status](https://img.shields.io/badge/version-v1.2.1-vividgreen.svg)](https://github.com/GabrielHCataldo/go-mongo-template/releases/tag/v1.2.1) +[![Project status](https://img.shields.io/badge/version-v1.2.2-vividgreen.svg)](https://github.com/GabrielHCataldo/go-mongo-template/releases/tag/v1.2.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) diff --git a/mongo/template.go b/mongo/template.go index dd4b954..e76a868 100644 --- a/mongo/template.go +++ b/mongo/template.go @@ -614,6 +614,7 @@ func (t *Template) FindPageable(ctx context.Context, filter any, input PageInput return nil, err } opt := option.MergeFindPageableByParams(opts) + skip := input.Page * input.PageSize cursor, err := collection.Find(ctx, filter, &options.FindOptions{ AllowDiskUse: opt.AllowDiskUse, AllowPartialResults: opt.AllowPartialResults, @@ -631,7 +632,7 @@ func (t *Template) FindPageable(ctx context.Context, filter any, input PageInput Projection: opt.Projection, ReturnKey: opt.ReturnKey, ShowRecordID: opt.ShowRecordID, - Skip: &input.Page, + Skip: &skip, Sort: input.Sort, Let: opt.Let, })