database

package
v0.0.0-...-3c02646 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	*ent.Client
	// contains filtered or unexported fields
}

Database holds the database configuration for the internal ORM. This allows a driver-agnostic way to configure and startup Response leaving all driver-specific configuration to each individual driver's implementation.

func Configure

func Configure(ctx context.Context, options *Options) (*Database, error)

Configure configures and opens a new connection to the database and returns a Database instance that can be used for manipulating the database graph with the generated ent client.

type Driver

type Driver string

Driver is a specifid database driver used to store persisted data in Response.

const (
	// EmbeddedDriver provides an in-memory storage implementation based on sqlite3's in-memory
	// database. This should not be used in production as data is not persisted.
	EmbeddedDriver Driver = "embedded"
)
const (
	// PostgresDriver implements storage using a supported PostgreSQL version (currently only 10, 11, or 12).
	// This driver is safe for production use and is the preferred production database.
	PostgresDriver Driver = "postgres"
)
const (
	// SQLiteDriver uses an SQLite3 implementation that stores a file at ./data/db.sqlite by default.
	// This path can be configured. This driver is not intended for production and should only be used
	// when persisting is necessary for development or testing purposes.
	SQLiteDriver Driver = "sqlite"
)

func (*Driver) Configure

func (d *Driver) Configure(ctx context.Context) (*ent.Client, error)

Configure configures the provided Database as the implemented driver.

type Options

type Options struct {
	Driver   Driver
	Path     string
	URL      string
	Host     string
	Port     int
	Name     string
	Username string
	Password string
	Options  map[string]string
	Debug    bool
	Logger   log.ComponentLogger
}

Jump to

Keyboard shortcuts

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