db

package
v0.0.0-...-8277694 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

database abstraction layer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	// implements mailsotre.MailRouter
	mailstore.MailRouter
	// implements pop3.UserAuthenticator
	CheckUserLogin(username, password string) (bool, error)
	// ensure that all migrations are done
	Ensure() error
	// visit every user and call a visitor
	VisitAllUsers(v UserVisitor) error
	// visit 1 user by email
	VisitUser(email string, v UserVisitor) error
	// create a new user, initialize values with i, visit after created with v
	CreateUser(i UserInitializer, v UserVisitor) error
	// ensure a user exists, intialize other members with i if it doesn't exist
	EnsureUser(name string, i UserInitializer) error
	// update a user that already exists, does nothing if it doesn't exist
	UpdateUser(name string, u UserUpdater) error

	// run db mainloop
	Run()
	// close access to database, all operations fail on this object after calling
	Close() error
}

db abstraction

func NewDB

func NewDB(dburl string) (db DB, err error)

create database driver

type UserInitializer

type UserInitializer func(*model.User) error

a callback that initializes a new user model safely

type UserUpdater

type UserUpdater func(*model.User) *model.User

a callback that updates a user model, returns updated model or nil for "don't update"

type UserVisitor

type UserVisitor func(*model.User) error

a callback that visits a user model safely

Jump to

Keyboard shortcuts

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