mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 02:38:35 +00:00
Use db.Find instead of writing methods for every object (#28084)
For those simple objects, it's unnecessary to write the find and count methods again and again.
This commit is contained in:
@@ -264,3 +264,8 @@ func inTransaction(ctx context.Context) (*xorm.Session, bool) {
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
|
||||
func Exists[T any](ctx context.Context, opts FindOptions) (bool, error) {
|
||||
var bean T
|
||||
return GetEngine(ctx).Where(opts.ToConds()).Exist(&bean)
|
||||
}
|
||||
|
Reference in New Issue
Block a user