mongodb

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mongodb implements the generic Better Auth database adapter contract.

Index

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 New

func New(config Config) (*Adapter, error)

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 (*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) EnsureCoreIndexes

func (a *Adapter) EnsureCoreIndexes(ctx context.Context) error

func (*Adapter) EnsureIndexes

func (a *Adapter) EnsureIndexes(ctx context.Context, schema betterauth.Schema) error

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 (*Adapter) ID

func (a *Adapter) ID() string

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 (*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
}

Jump to

Keyboard shortcuts

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