mirror of
https://github.com/go-gitea/gitea.git
synced 2025-04-08 17:05:45 +02:00
chore: remove FindObjects
This commit is contained in:
parent
f8d8209edb
commit
aee01d139c
@ -3,12 +3,6 @@
|
||||
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"xorm.io/builder"
|
||||
)
|
||||
|
||||
// SearchOrderBy is used to sort the result
|
||||
type SearchOrderBy string
|
||||
|
||||
@ -33,15 +27,3 @@ const (
|
||||
SearchOrderByForks SearchOrderBy = "num_forks ASC"
|
||||
SearchOrderByForksReverse SearchOrderBy = "num_forks DESC"
|
||||
)
|
||||
|
||||
// FindObjects represents a common function to find Objects from database according cond and ListOptions
|
||||
func FindObjects[Object any](ctx context.Context, cond builder.Cond, opts *ListOptions, objects *[]*Object) error {
|
||||
sess := GetEngine(ctx).Where(cond)
|
||||
if opts != nil && opts.PageSize > 0 {
|
||||
if opts.Page < 1 {
|
||||
opts.Page = 1
|
||||
}
|
||||
sess.Limit(opts.PageSize, opts.PageSize*(opts.Page-1))
|
||||
}
|
||||
return sess.Find(objects)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user