1package db
2
3import (
4 "context"
5 "errors"
6
7 "github.com/jmoiron/sqlx"
8)
9
10var (
11 // ErrNoDatabase is returned when no database is found in the context.
12 ErrNoDatabase = errors.New("no database found")
13)
14
15// Database is the interface that wraps basic database operations.
16type Database interface {
17 // Close closes the database connection.
18 Close() error
19 // Open opens a new database connection.
20 Open(ctx context.Context, url string) (Database, error)
21 // Migrate runs database migrations.
22 Migrate(url string) error
23 // DBx returns the underlying sqlx database.
24 DBx() *sqlx.DB
25}