Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TransformSelectQuery ¶
func TransformSelectQuery(ctx context.Context, query *bun.SelectQuery, sqts ...SelectQueryTransformer) (*bun.SelectQuery, error)
TransformSelectQuery applies the given transformers to the query.
Types ¶
type ClientRepo ¶
type SelectQueryTransformer ¶
type SelectQueryTransformer interface {
Transform(context.Context, *bun.SelectQuery) (*bun.SelectQuery, error)
}
SelectQueryTransformer is an interface for transforming bun.SelectQuery.
func WithColumns ¶
func WithColumns(columns ...string) SelectQueryTransformer
WithColumns is a bun.SelectQuery transformer that adds columns to the query. The columns to include/exclude can be specified as variadic arguments. To exclude a column, prefix it with a minus sign.
- Parameters:
- columns: The columns to include/exclude.
Example 1: WithColumns("id", "name")
Example 2: WithColumns("id", "-name")
Example 3: WithColumns("-*", "name")
func WithPagination ¶
func WithPagination(p interface {
GetPage() int32
GetSize() int32
}) SelectQueryTransformer
WithPagination is a bun.SelectQuery transformer that adds paging to the query. The page and size can be specified by the given interface.
func WithRelation ¶
func WithRelation(relation string, columns ...string) SelectQueryTransformer
WithRelation is a bun.SelectQuery transformer that adds a relation to the query. The columns to include/exclude can be specified as variadic arguments. To exclude a column, prefix it with a minus sign.
- Parameters:
- relation: The relation name.
- columns: The columns to include/exclude.
Example 1: WithRelation("Realm")
Example 2: WithRelation("Realm", "name")
Example 3: WithRelation("Realm", "-*", "name")
type SelectQueryTransformerFunc ¶
type SelectQueryTransformerFunc func(context.Context, *bun.SelectQuery) (*bun.SelectQuery, error)
SelectQueryTransformerFunc is a function that transforms bun.SelectQuery.
func (SelectQueryTransformerFunc) Transform ¶
func (f SelectQueryTransformerFunc) Transform(ctx context.Context, query *bun.SelectQuery) (*bun.SelectQuery, error)
SelectQueryTransformerFunc is a function that implements SelectQueryTransformer.
type UserRepo ¶
type UserRepo interface {
Find(ctx context.Context, sqts ...SelectQueryTransformer) ([]*models.User, int64, error)
FindByID(ctx context.Context, id string, sqts ...SelectQueryTransformer) (*models.User, error)
Create(ctx context.Context, user *models.User) error
UpdateLoginStatus(ctx context.Context, userId string, now time.Time) error
}