bolt

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2018 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Overview

Package bolt provides a boltdb implementation of the justanotherbotkit/users/DB interface. It provides this in the form of 2 event driven snapshot buckets; this means that the snapshot bucket will always retain a previous version of a DB record. While the context arguments are currently ignored future updates will use the context to house metadata pertaining to a given change.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// File is the bolt db path/name.
	File string
	// Options are the bolt db options.
	Options *bolt.Options
}

Config is a database config.

func (*Config) Validate

func (c *Config) Validate() error

Validate a configuration, applying defaults where possible.

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB provides a Bolt implementation of a users.DB

func New

func New(cfg *Config) (db *DB, err error)

New returns a new users.DB running over bolt.

func (*DB) CreateUser

func (db *DB) CreateUser(ctx context.Context, u users.User) (users.User, error)

CreateUser creates a new user and saves it to the database.

func (*DB) DeleteUser

func (db *DB) DeleteUser(ctx context.Context, id string) (users.User, error)

DeleteUser deletes a user record from the database.

func (*DB) GetUser

func (db *DB) GetUser(ctx context.Context, id string) (users.User, error)

GetUser gets a user from the database using the ID.

func (*DB) UpdateUser

func (db *DB) UpdateUser(ctx context.Context, u users.User) (users.User, error)

UpdateUser updates a user record in the database.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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