Documentation
¶
Overview ¶
Package db is glabs-web's MongoDB layer. It owns the connection and the collection access; everything above it works with the decoded documents.
Index ¶
- type DB
- func (db *DB) CountUsers(ctx context.Context) (int64, error)
- func (db *DB) Disconnect(ctx context.Context) error
- func (db *DB) EnsureUserIndexes(ctx context.Context) error
- func (db *DB) GetUserByEmail(ctx context.Context, email string) (*model.User, error)
- func (db *DB) SaveUser(ctx context.Context, user *model.User) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func Connect ¶
Connect opens the connection and verifies it with a ping, so a bad URI fails at startup rather than on the first query.
UseLocalTimeZone decodes the UTC that Mongo stores back into time.Local, which main sets to Europe/Berlin — so timestamps read out in the zone they were written in.
func (*DB) CountUsers ¶
CountUsers reports how many users exist, so seeding can run only on an empty allowlist.
func (*DB) EnsureUserIndexes ¶
EnsureUserIndexes makes the email unique. Called once at startup.
func (*DB) GetUserByEmail ¶
GetUserByEmail returns the user with the given email, or nil if there is none. The auth middleware treats nil as "not on the allowlist" — a 403 — so a missing user must be nil, nil rather than an error.