update-limit #15

Merged
sinhluu merged 2 commits from update-limit into master 2023-04-05 11:03:08 +00:00
1 changed files with 6 additions and 1 deletions
Showing only changes of commit 29157b2530 - Show all commits

View File

@ -7,6 +7,8 @@ import (
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
) )
const maxLimit = 500
// CommonQuery ... // CommonQuery ...
type CommonQuery struct { type CommonQuery struct {
Page int64 Page int64
@ -78,9 +80,12 @@ func (q *CommonQuery) GetFindOptionsUsingPage() *options.FindOptions {
// SetDefaultLimit ... // SetDefaultLimit ...
func (q *CommonQuery) SetDefaultLimit() { func (q *CommonQuery) SetDefaultLimit() {
if q.Limit <= 0 || q.Limit > 20 { if q.Limit <= 0 {
q.Limit = 20 q.Limit = 20
} }
if q.Limit > maxLimit {
q.Limit = 500
}
} }
// AssignOther ... // AssignOther ...