defaultstore

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package defaultstore implements the SQL-backed default store for the admin plugin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultAdminStore

type DefaultAdminStore struct {
	// contains filtered or unexported fields
}

DefaultAdminStore implements admintypes.Store using a SQL database.

Supports PostgreSQL, MySQL, and SQLite through dialect-specific sqlc-generated queries. Safe for concurrent use.

func NewDefaultAdminStore

func NewDefaultAdminStore(db *sql.DB, dialect plugins.Dialect) (*DefaultAdminStore, error)

NewDefaultAdminStore creates a DefaultAdminStore for the given dialect. The dialect switch happens exactly once here; all store methods call through the querier interface and are dialect-agnostic.

func (*DefaultAdminStore) AssignRole

func (s *DefaultAdminStore) AssignRole(ctx context.Context, userID, role string) error

AssignRole assigns a role to a user.

func (*DefaultAdminStore) BanUser

func (s *DefaultAdminStore) BanUser(ctx context.Context, userID, reason string, expiry *time.Time) error

BanUser bans a user.

func (*DefaultAdminStore) Count

func (s *DefaultAdminStore) Count(ctx context.Context) (int, error)

Count returns the total number of users.

func (*DefaultAdminStore) Create

Create creates a new user.

func (*DefaultAdminStore) Delete

func (s *DefaultAdminStore) Delete(ctx context.Context, id string) error

Delete soft-deletes a user.

func (*DefaultAdminStore) GetByEmail

func (s *DefaultAdminStore) GetByEmail(ctx context.Context, email string) (admintypes.User, error)

GetByEmail retrieves a user by email.

func (*DefaultAdminStore) GetByID

func (s *DefaultAdminStore) GetByID(ctx context.Context, id string) (admintypes.User, error)

GetByID retrieves a user by ID.

func (*DefaultAdminStore) GetRole

func (s *DefaultAdminStore) GetRole(ctx context.Context, userID string) (string, error)

GetRole retrieves a user's role.

func (*DefaultAdminStore) GetStats

GetStats retrieves system statistics.

func (*DefaultAdminStore) GetUserRaw

func (s *DefaultAdminStore) GetUserRaw(ctx context.Context, userID string) (map[string]any, error)

GetUserRaw retrieves a single user as raw map data.

func (*DefaultAdminStore) List

func (s *DefaultAdminStore) List(ctx context.Context, offset, limit int) ([]admintypes.User, error)

List retrieves a paginated list of users.

func (*DefaultAdminStore) ListUsersRaw

func (s *DefaultAdminStore) ListUsersRaw(ctx context.Context, offset, limit int) ([]map[string]any, error)

ListUsersRaw retrieves a paginated list of users as raw map data.

func (*DefaultAdminStore) RemoveRole

func (s *DefaultAdminStore) RemoveRole(ctx context.Context, userID string, _ string) error

RemoveRole removes a role from a user by resetting it to "user".

func (*DefaultAdminStore) UnbanUser

func (s *DefaultAdminStore) UnbanUser(ctx context.Context, userID string) error

UnbanUser unbans a user.

func (*DefaultAdminStore) Update

func (s *DefaultAdminStore) Update(ctx context.Context, user admintypes.User) error

Update updates user information.

Jump to

Keyboard shortcuts

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