This commit is contained in:
xing 2023-02-06 18:42:36 +08:00
parent 4ec03cba9b
commit b1859409da

View File

@ -171,21 +171,11 @@ func DBPagination[T Model](db dbQuery, ctx context.Context, q *QueryCondition) (
return pagination[T](db, ctx, q.where, q.fields, q.group, q.page, q.limit, q.order, q.join, q.having, q.in...) return pagination[T](db, ctx, q.where, q.fields, q.group, q.page, q.limit, q.order, q.join, q.having, q.in...)
} }
func Column[V Model, T any](ctx context.Context, fn func(V) (T, bool), q *QueryCondition) (r []T, err error) { func Column[V Model, T any](ctx context.Context, fn func(V) (T, bool), q *QueryCondition) ([]T, error) {
res, err := finds[V](globalBb, ctx, q) return column[V, T](globalBb, ctx, fn, q)
if err != nil {
return nil, err
}
r = slice.FilterAndMap(res, fn)
return
} }
func DBColumn[V Model, T any](db dbQuery, ctx context.Context, fn func(V) (T, bool), q *QueryCondition) (r []T, err error) { func DBColumn[V Model, T any](db dbQuery, ctx context.Context, fn func(V) (T, bool), q *QueryCondition) (r []T, err error) {
res, err := finds[V](db, ctx, q) return column[V, T](db, ctx, fn, q)
if err != nil {
return nil, err
}
r = slice.FilterAndMap(res, fn)
return
} }
func column[V Model, T any](db dbQuery, ctx context.Context, fn func(V) (T, bool), q *QueryCondition) (r []T, err error) { func column[V Model, T any](db dbQuery, ctx context.Context, fn func(V) (T, bool), q *QueryCondition) (r []T, err error) {