sqlite

package module
v0.0.0-...-5f42b01 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: BSD-3-Clause Imports: 5 Imported by: 0

README

Joe Bot - Sqlite Storage

Sqlite memory adapater. https://github.com/go-joe/joe

Sqlite memory backend for: https://github.com/go-joe/joe

Examples

b := &ExampleBot{
	Bot: joe.New("example", sqlite.Memory(":memory:")),
}

or for a persistent DB:

b := &ExampleBot{
	Bot: joe.New("example", sqlite.Memory("file:example.db")),
}

Documentation

Index

Constants

View Source
const KeysTable = "keys"

Variables

This section is empty.

Functions

func Memory

func Memory(dsn string) joe.Module

Memory is a joe.Option which is supposed to be passed to joe.New(…) to configure a new bot. The dsn is passed to Sqlite to open the DB. This could be a path to a file or in-memory DB:

https://godoc.org/github.com/mattn/go-sqlite3#SQLiteDriver.Open

If the DB already exists it will be opened, otherwise it will be created and initialised. If the file exists but cannot be opened its error will be deferred until the bot is actually started via its Run() function.

Example usage:

b := joe.New("example",
    sqlite.Memory(":memory:"),
    …
)

func NewMemory

func NewMemory(dsn string, opts ...Option) (joe.Memory, error)

NewMemory will create a new sqlite Memory instance and set up the DB to be used with a joe bot.

Types

type Option

type Option func(*memory) error

Option corresponds to a configuration setting of the file memory. All available options are the exported functions of this package that share the prefix "With" in their names.

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger is a memory option that allows the caller to set a different logger. By default this option is not required because the file.Memory(…) function automatically uses the logger of the given joe.Config.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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