Documentation
¶
Overview ¶
Package sqladapter implements the shared database/sql adapter used by the PostgreSQL and SQLite dialect packages.
Index ¶
- type Adapter
- func (adapter *Adapter) Capabilities() betterauth.AdapterCapabilities
- func (adapter *Adapter) CheckSchema(ctx context.Context, schema betterauth.Schema) ([]betterauth.SchemaFinding, error)
- func (adapter *Adapter) ConsumeOne(ctx context.Context, query betterauth.DeleteQuery) (betterauth.Record, error)
- func (adapter *Adapter) Count(ctx context.Context, query betterauth.CountQuery) (int64, error)
- func (adapter *Adapter) Create(ctx context.Context, query betterauth.CreateQuery) (betterauth.Record, error)
- func (adapter *Adapter) Delete(ctx context.Context, query betterauth.DeleteQuery) error
- func (adapter *Adapter) DeleteMany(ctx context.Context, query betterauth.DeleteQuery) (int64, error)
- func (adapter *Adapter) FindMany(ctx context.Context, query betterauth.FindManyQuery) ([]betterauth.Record, error)
- func (adapter *Adapter) FindOne(ctx context.Context, query betterauth.FindOneQuery) (betterauth.Record, error)
- func (adapter *Adapter) ID() string
- func (adapter *Adapter) IncrementOne(ctx context.Context, query betterauth.IncrementQuery) (betterauth.Record, error)
- func (adapter *Adapter) Migrate(ctx context.Context, schema betterauth.Schema) error
- func (adapter *Adapter) SchemaName() string
- func (adapter *Adapter) Transaction(ctx context.Context, callback func(betterauth.DatabaseAdapter) error) error
- func (adapter *Adapter) Update(ctx context.Context, query betterauth.UpdateQuery) (betterauth.Record, error)
- func (adapter *Adapter) UpdateMany(ctx context.Context, query betterauth.UpdateQuery) (int64, error)
- func (adapter *Adapter) WithSchema(schema betterauth.Schema) (betterauth.DatabaseAdapter, error)
- type Dialect
- type Options
- type UnsafeMigrationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter is a schema-aware database/sql adapter. Call Migrate explicitly before serving requests.
func NewWithOptions ¶ added in v1.1.0
NewWithOptions is New with optional settings. A SchemaName is rejected for any dialect other than PostgreSQL.
func (*Adapter) Capabilities ¶
func (adapter *Adapter) Capabilities() betterauth.AdapterCapabilities
func (*Adapter) CheckSchema ¶ added in v1.1.0
func (adapter *Adapter) CheckSchema( ctx context.Context, schema betterauth.Schema, ) ([]betterauth.SchemaFinding, error)
CheckSchema reads the live tables that schema writes and returns every problem DiffSchema finds. On PostgreSQL it looks only in the configured schema when one is set, and otherwise in the first schema on the search_path that holds a table or view with that name. It implements betterauth.SchemaChecker.
func (*Adapter) ConsumeOne ¶
func (adapter *Adapter) ConsumeOne(ctx context.Context, query betterauth.DeleteQuery) (betterauth.Record, error)
func (*Adapter) Count ¶
func (adapter *Adapter) Count(ctx context.Context, query betterauth.CountQuery) (int64, error)
func (*Adapter) Create ¶
func (adapter *Adapter) Create(ctx context.Context, query betterauth.CreateQuery) (betterauth.Record, error)
func (*Adapter) Delete ¶
func (adapter *Adapter) Delete(ctx context.Context, query betterauth.DeleteQuery) error
func (*Adapter) DeleteMany ¶
func (adapter *Adapter) DeleteMany(ctx context.Context, query betterauth.DeleteQuery) (int64, error)
func (*Adapter) FindMany ¶
func (adapter *Adapter) FindMany(ctx context.Context, query betterauth.FindManyQuery) ([]betterauth.Record, error)
func (*Adapter) FindOne ¶
func (adapter *Adapter) FindOne(ctx context.Context, query betterauth.FindOneQuery) (betterauth.Record, error)
func (*Adapter) IncrementOne ¶
func (adapter *Adapter) IncrementOne(ctx context.Context, query betterauth.IncrementQuery) (betterauth.Record, error)
func (*Adapter) Migrate ¶
Migrate creates missing tables and indexes for the supplied merged schema. It is additive and never drops or rewrites an existing column.
func (*Adapter) SchemaName ¶ added in v1.1.0
SchemaName returns the configured PostgreSQL schema, or "" when statements use the connection's search_path.
func (*Adapter) Transaction ¶
func (adapter *Adapter) Transaction(ctx context.Context, callback func(betterauth.DatabaseAdapter) error) error
func (*Adapter) Update ¶
func (adapter *Adapter) Update(ctx context.Context, query betterauth.UpdateQuery) (betterauth.Record, error)
func (*Adapter) UpdateMany ¶
func (adapter *Adapter) UpdateMany(ctx context.Context, query betterauth.UpdateQuery) (int64, error)
func (*Adapter) WithSchema ¶
func (adapter *Adapter) WithSchema(schema betterauth.Schema) (betterauth.DatabaseAdapter, error)
type Options ¶ added in v1.1.0
type Options struct {
// SchemaName is the PostgreSQL schema (namespace) that holds Better
// Auth's tables. When set, every statement names the table as
// "schema"."table", so the adapter no longer depends on the connection's
// search_path, and Migrate creates the schema before it creates tables.
// It matches Better Auth's database.schemaName and is PostgreSQL only.
SchemaName string
}
Options holds optional adapter settings.
type UnsafeMigrationError ¶ added in v1.1.0
UnsafeMigrationError reports an additive migration that would add a required column without a static default to a populated table.
func (*UnsafeMigrationError) Error ¶ added in v1.1.0
func (err *UnsafeMigrationError) Error() string