authadapter

package
v0.0.0-...-36d6306 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package authadapter translates BetterAuth adapter JSON calls into typed sqlc queries.

Index

Constants

View Source
const (
	ModelUser         = "user"
	ModelSession      = "session"
	ModelAccount      = "account"
	ModelVerification = "verification"
	ModelJwks         = "jwks"
)

Variables

View Source
var (
	ErrUnsupportedModel = errors.New("authadapter: unsupported model")
	ErrUnsupportedWhere = errors.New("authadapter: unsupported where clause")
	ErrInvalidID        = errors.New("authadapter: invalid ID format")
)

Functions

This section is empty.

Types

type Adapter

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

Adapter dispatches BetterAuth adapter calls to typed sqlc queries.

func New

func New(q *gen.Queries, db gen.DBTX) *Adapter

New creates an Adapter backed by the given queries and database connection. The db parameter is used for dynamic SQL queries (findMany, updateMany) that cannot be expressed through sqlc.

func (*Adapter) Count

func (a *Adapter) Count(ctx context.Context, model string) (int64, error)

func (*Adapter) Create

func (a *Adapter) Create(ctx context.Context, model string, data map[string]json.RawMessage) (map[string]any, error)

func (*Adapter) Delete

func (a *Adapter) Delete(ctx context.Context, model string, where []WhereClause) error

func (*Adapter) DeleteMany

func (a *Adapter) DeleteMany(ctx context.Context, model string, where []WhereClause) error

func (*Adapter) FindMany

func (a *Adapter) FindMany(ctx context.Context, model string, where []WhereClause, opts FindManyOpts) ([]map[string]any, error)

func (*Adapter) FindOne

func (a *Adapter) FindOne(ctx context.Context, model string, where []WhereClause) (map[string]any, error)

func (*Adapter) Update

func (a *Adapter) Update(ctx context.Context, model string, where []WhereClause, data map[string]json.RawMessage) (map[string]any, error)

func (*Adapter) UpdateMany

func (a *Adapter) UpdateMany(ctx context.Context, model string, where []WhereClause, data map[string]json.RawMessage) (int64, error)

type FindManyOpts

type FindManyOpts struct {
	SortBy *SortBy
	Limit  int32
	Offset int32
}

FindManyOpts holds optional parameters for FindMany.

type SortBy

type SortBy struct {
	Field     string
	Direction string // "asc" or "desc"
}

SortBy describes a sort order for FindMany queries.

type WhereClause

type WhereClause struct {
	Field     string          `json:"field"`
	Operator  string          `json:"operator"`
	Value     json.RawMessage `json:"value"`
	Connector string          `json:"connector"`
}

WhereClause mirrors the BetterAuth CleanedWhere type sent over JSON.

Jump to

Keyboard shortcuts

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