Skip to content

Commit

Permalink
add the ability to set Field
Browse files Browse the repository at this point in the history
  • Loading branch information
LikDan committed May 9, 2024
1 parent 270e11e commit ca00bfb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion databases/pagination/created_at_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@ type CreatedAtPageQuery struct {
QPage int `json:"page"`
QPerPage int `json:"perPage"`
QOrder string `json:"order"`
QField string `json:"field"`
}

func (c *CreatedAtPageQuery) Field() string {
return "created_at"
if c.QField == "" {
return "created_at"
}

return c.QField
}

func (c *CreatedAtPageQuery) SetField(field string) {
c.QField = field
}

func (c *CreatedAtPageQuery) Order() string {
Expand Down
2 changes: 2 additions & 0 deletions databases/pagination/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package pagination

type Query interface {
Field() string
SetField(field string)

Order() string
Cursor() any
PerPage() int
Expand Down

0 comments on commit ca00bfb

Please sign in to comment.