dbr

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// And creates AND from a list of conditions.
	And = dbr.And
	// Or creates OR from a list of conditions.
	Or = dbr.Or
	// Eq is `=`.
	// When value is nil, it will be translated to `IS NULL`.
	// When value is a slice, it will be translated to `IN`.
	// Otherwise it will be translated to `=`.
	Eq = dbr.Eq
	// Neq is `!=`.
	// When value is nil, it will be translated to `IS NOT NULL`.
	// When value is a slice, it will be translated to `NOT IN`.
	// Otherwise it will be translated to `!=`.
	Neq = dbr.Neq
	// Gt is `>`.
	Gt = dbr.Gt
	// Gte is '>='.
	Gte = dbr.Gte
	// Lt is '<'.
	Lt = dbr.Lt
	// Lte is `<=`.
	Lte = dbr.Lte
	// Like is `LIKE`, with an optional `ESCAPE` clause
	Like = dbr.Like
	// NotLike is `NOT LIKE`, with an optional `ESCAPE` clause
	NotLike = dbr.NotLike
	// Expr allows raw expression to be used when current SQL syntax is
	// not supported by gocraft/dbr.
	Expr = dbr.Expr
	// Union builds
	Union = dbr.Union
	// UnionAll builds
	UnionAll = dbr.UnionAll
)

export dbr expression function for convenience

Functions

func Middleware

func Middleware(db *DB) b.Middleware

Middleware inject dbr session to context

Types

type DB added in v0.25.6

type DB struct {
	*dbr.Session
}

DB session instance, base on dbr.Session

func Dbr added in v0.20.0

func Dbr(ctx context.Context) *DB

Dbr get dbr session from context

func New

func New(optionalDSN ...string) *DB

New dbr.Session if optionalDSN is omited, mysql.dsn in config.yml will be used Supported config(config.yml): mysql.dsn - dsn for connection mysql.maxIdleConns - max idle connections for pool mysql.maxOpenConns - max open connections for pool

type Logger

type Logger struct {
	*bl.Logger
	*dbr.EventReceiver
}

Logger for dbr

func (*Logger) Event

func (l *Logger) Event(eventName string)

Event func

func (*Logger) EventErr

func (l *Logger) EventErr(eventName string, err error) error

EventErr func

func (*Logger) EventErrKv

func (l *Logger) EventErrKv(eventName string, err error, kvs map[string]string) error

EventErrKv func

func (*Logger) EventKv

func (l *Logger) EventKv(eventName string, kvs map[string]string)

EventKv func

func (*Logger) Timing

func (l *Logger) Timing(eventName string, nanoseconds int64)

Timing func

func (*Logger) TimingKv

func (l *Logger) TimingKv(eventName string, nanoseconds int64, kvs map[string]string)

TimingKv func

Jump to

Keyboard shortcuts

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