mirror of
https://github.com/go-gitea/gitea
synced 2025-07-26 20:28:40 +00:00
chore: remove FindObjects
This commit is contained in:
@@ -3,12 +3,6 @@
|
|||||||
|
|
||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"xorm.io/builder"
|
|
||||||
)
|
|
||||||
|
|
||||||
// SearchOrderBy is used to sort the result
|
// SearchOrderBy is used to sort the result
|
||||||
type SearchOrderBy string
|
type SearchOrderBy string
|
||||||
|
|
||||||
@@ -33,15 +27,3 @@ const (
|
|||||||
SearchOrderByForks SearchOrderBy = "num_forks ASC"
|
SearchOrderByForks SearchOrderBy = "num_forks ASC"
|
||||||
SearchOrderByForksReverse SearchOrderBy = "num_forks DESC"
|
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)
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user