repos

package
v0.0.0-...-2d8f2a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 5 Imported by: 0

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 ClientRepo interface {
	FindBySecretKey(ctx context.Context, secretKey string, sqts ...SelectQueryTransformer) (*models.Client, error)
}

type DataRepos

type DataRepos interface {
	RunInTx(context.Context, *sql.TxOptions, func(context.Context, DataRepos) error) error
	Clients() ClientRepo
	Realms() RealmRepo
	Users() UserRepo
	Roles() RoleRepo
	Logins() LoginRepo
}

type LoginRepo

type LoginRepo interface {
	CreateLogin(ctx context.Context, login *models.Login) error
	FindByIdentifier(ctx context.Context, realmId, provider, identifier string, sqts ...SelectQueryTransformer) (*models.Login, error)
	DisableById(ctx context.Context, id string) error
}

type RealmRepo

type RealmRepo interface {
	FindByName(ctx context.Context, name string, sqts ...SelectQueryTransformer) (*models.Realm, error)
}

type RoleRepo

type RoleRepo interface {
	FindNamesByUser(ctx context.Context, userId string, sqts ...SelectQueryTransformer) ([]string, int64, error)
}

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

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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址