Documentation
¶
Overview ¶
Package mongodb implements the generic Better Auth database adapter contract.
Index ¶
- type Adapter
- func (a *Adapter) Capabilities() betterauth.AdapterCapabilities
- func (a *Adapter) ConsumeOne(ctx context.Context, query betterauth.DeleteQuery) (betterauth.Record, error)
- func (a *Adapter) Count(ctx context.Context, query betterauth.CountQuery) (int64, error)
- func (a *Adapter) Create(ctx context.Context, query betterauth.CreateQuery) (betterauth.Record, error)
- func (a *Adapter) Delete(ctx context.Context, query betterauth.DeleteQuery) error
- func (a *Adapter) DeleteMany(ctx context.Context, query betterauth.DeleteQuery) (int64, error)
- func (a *Adapter) EnsureCoreIndexes(ctx context.Context) error
- func (a *Adapter) EnsureIndexes(ctx context.Context, schema betterauth.Schema) error
- func (a *Adapter) FindMany(ctx context.Context, query betterauth.FindManyQuery) ([]betterauth.Record, error)
- func (a *Adapter) FindOne(ctx context.Context, query betterauth.FindOneQuery) (betterauth.Record, error)
- func (a *Adapter) ID() string
- func (a *Adapter) IncrementOne(ctx context.Context, query betterauth.IncrementQuery) (betterauth.Record, error)
- func (a *Adapter) Transaction(ctx context.Context, callback func(betterauth.DatabaseAdapter) error) error
- func (a *Adapter) Update(ctx context.Context, query betterauth.UpdateQuery) (betterauth.Record, error)
- func (a *Adapter) UpdateMany(ctx context.Context, query betterauth.UpdateQuery) (int64, error)
- func (a *Adapter) WithSchema(schema betterauth.Schema) (betterauth.DatabaseAdapter, error)
- type Config
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
}
func (*Adapter) Capabilities ¶
func (a *Adapter) Capabilities() betterauth.AdapterCapabilities
func (*Adapter) ConsumeOne ¶
func (a *Adapter) ConsumeOne(ctx context.Context, query betterauth.DeleteQuery) (betterauth.Record, error)
func (*Adapter) Count ¶
func (a *Adapter) Count(ctx context.Context, query betterauth.CountQuery) (int64, error)
func (*Adapter) Create ¶
func (a *Adapter) Create(ctx context.Context, query betterauth.CreateQuery) (betterauth.Record, error)
func (*Adapter) Delete ¶
func (a *Adapter) Delete(ctx context.Context, query betterauth.DeleteQuery) error
func (*Adapter) DeleteMany ¶
func (a *Adapter) DeleteMany(ctx context.Context, query betterauth.DeleteQuery) (int64, error)
func (*Adapter) EnsureIndexes ¶
EnsureIndexes creates indexes declared by the fully merged core/application/ plugin schema plus the core compound and TTL indexes. Call it with Server.Schema after constructing the server.
func (*Adapter) FindMany ¶
func (a *Adapter) FindMany(ctx context.Context, query betterauth.FindManyQuery) ([]betterauth.Record, error)
func (*Adapter) FindOne ¶
func (a *Adapter) FindOne(ctx context.Context, query betterauth.FindOneQuery) (betterauth.Record, error)
func (*Adapter) IncrementOne ¶
func (a *Adapter) IncrementOne(ctx context.Context, query betterauth.IncrementQuery) (betterauth.Record, error)
func (*Adapter) Transaction ¶
func (a *Adapter) Transaction(ctx context.Context, callback func(betterauth.DatabaseAdapter) error) error
func (*Adapter) Update ¶
func (a *Adapter) Update(ctx context.Context, query betterauth.UpdateQuery) (betterauth.Record, error)
func (*Adapter) UpdateMany ¶
func (a *Adapter) UpdateMany(ctx context.Context, query betterauth.UpdateQuery) (int64, error)
func (*Adapter) WithSchema ¶ added in v1.1.0
func (a *Adapter) WithSchema(schema betterauth.Schema) (betterauth.DatabaseAdapter, error)
WithSchema checks that the schema and Config.Collections do not both rename models. The adapter receives stored model names, so it maps a stored name to a collection through Collections only when the schema keeps the logical names. Mixing the two could write rows to the wrong collection.
type Config ¶
type Config struct {
Database *mongo.Database
// Collections renames the collection of a model, keyed by model name. Use
// either Collections or the schema's ModelName to rename models, not
// both: a server rejects the mix, because the adapter only sees stored
// model names and could not tell which rename applies.
Collections map[string]string
}