data

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package data handles all the data and application structures handling for Lex Library

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeginTx

func BeginTx(trnFunc func(tx *sql.Tx) error) error

BeginTx begins a transaction on the database If the function passed in returns an error, the transaction rolls back If it returns a nil error, then the transaction commits

func Init

func Init(cfg Config) error

Init initializes the data layer based on the passed in configuration. Initialization includes things like setting up the database and the connections to it.

func Teardown

func Teardown() error

Teardown cleanly tears down any data layer connections

Types

type Config

type Config struct {
	DatabaseFile string
	SearchFile   string

	DatabaseType string
	DatabaseURL  string

	SSLCert     string
	SSLKey      string
	SSLRootCert string

	MaxIdleConnections    int
	MaxOpenConnections    int
	MaxConnectionLifetime string

	AllowSchemaRollback bool
}

Config is the data layer configuration used to determine how to initialize the data layer

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration for the data layer

type Query

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

Query is a templated query that can run across multiple database backends

func NewQuery

func NewQuery(tmpl string) *Query

NewQuery creates a new query from the template passed in

func (*Query) Debug

func (q *Query) Debug(args ...sql.NamedArg) string

Debug runs the passed in query and returns a string of the results in a tab delimited format, with columns listed in the first row meant for debugging use. Will panic instead of throwing an error

func (*Query) DebugPrint

func (q *Query) DebugPrint(args ...sql.NamedArg)

DebugPrint prints out the debug query to the screen

func (*Query) Exec

func (q *Query) Exec(args ...sql.NamedArg) (sql.Result, error)

Exec executes a templated query without returning any rows

func (*Query) Query

func (q *Query) Query(args ...sql.NamedArg) (*sql.Rows, error)

Query executes a templated query that returns rows

func (*Query) QueryRow

func (q *Query) QueryRow(args ...sql.NamedArg) *sql.Row

QueryRow executes a templated query that returns a single row

func (*Query) Statement

func (q *Query) Statement() string

Statement returns the complied query template

func (*Query) String

func (q *Query) String() string

func (*Query) Tx

func (q *Query) Tx(tx *sql.Tx) *Query

Tx returns a new copy of the query that runs in the passed in transaction

Jump to

Keyboard shortcuts

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