chore: remove FindObjects

This commit is contained in:
Jason Song 2022-12-22 15:16:10 +08:00
parent f8d8209edb
commit aee01d139c
No known key found for this signature in database
GPG Key ID: 8402EEEE4511A8B5

View File

@ -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)
}