dw

package
v0.0.0-...-b8eaa0e Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package dw is a wrapper layer.

This package gives you wrappers of sql.DB, sql.Tx and ef package functions.

Most functions/methos are helpers to ef package functions. This package gives you fewer arguments and transparency to sql.DB methods. e.g.

before:
  db, _ := sql.Open(...)
  stmt := cue.Select(...)
  query, args := stmt.BuildSQL()
  ef.FetchOne(db, &destStruct, query, args...)
after:
  db, _ := dw.Open(...) // same arguments
  stmt := cue.Select(...) // same
  db.FetchOne(&destStruct, stmt) // fewer lines, fewer arguments

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*sql.DB
}

DB wrapps *sql.DB

func Open

func Open(driverName, dataSourceName string) (*DB, error)

Open wrapps sql.Open and returns *dw.DB

func (*DB) Begin

func (db *DB) Begin() (*Tx, error)

Begin has same functionality of sql.DB's.

func (*DB) Create

func (db *DB) Create(table string, ifnotexists bool, tgt interface{}, optDialect ...dialect.Dialect) (sql.Result, error)

Create has same functionality of ef's.

func (*DB) Exec

func (db *DB) Exec(stmt cue.Builder) (sql.Result, error)

Exec has same functionality of ef's.

func (*DB) Exists

func (db *DB) Exists(stmt cue.Builder) (bool, error)

Exists has same functionality of ef's.

func (*DB) FetchAll

func (db *DB) FetchAll(dest interface{}, stmt cue.Builder) error

FetchAll has same functionality of ef's.

func (*DB) FetchEach

func (db *DB) FetchEach(sampleOfDest interface{}, stmt cue.Builder) (*ef.Rows, error)

FetchEach has same functionality of ef's.

func (*DB) FetchOne

func (db *DB) FetchOne(dest interface{}, stmt cue.Builder) error

FetchOne has same functionality of ef's.

func (*DB) Insert

func (db *DB) Insert(table string, tgt interface{}, optDialect ...dialect.Dialect) (sql.Result, error)

Insert has same functionality of ef's.

func (*DB) Update

func (db *DB) Update(table string, tgt interface{}, optDialect ...dialect.Dialect) (sql.Result, error)

Update has same functionality of ef's.

type Tx

type Tx struct {
	*sql.Tx
}

Tx wrapps *sql.Tx

func (*Tx) Create

func (tx *Tx) Create(table string, ifnotexists bool, tgt interface{}, optDialect ...dialect.Dialect) (sql.Result, error)

Create has same functionality of ef's.

func (*Tx) Exec

func (tx *Tx) Exec(stmt cue.Builder) (sql.Result, error)

Exec has same functionality of ef's.

func (*Tx) Exists

func (tx *Tx) Exists(stmt cue.Builder) (bool, error)

Exists has same functionality of ef's.

func (*Tx) FetchAll

func (tx *Tx) FetchAll(dest interface{}, stmt cue.Builder) error

FetchAll has same functionality of ef's.

func (*Tx) FetchEach

func (tx *Tx) FetchEach(sampleOfDest interface{}, stmt cue.Builder) (*ef.Rows, error)

FetchEach has same functionality of ef's.

func (*Tx) FetchOne

func (tx *Tx) FetchOne(dest interface{}, stmt cue.Builder) error

FetchOne has same functionality of ef's.

func (*Tx) Insert

func (tx *Tx) Insert(table string, tgt interface{}, optDialect ...dialect.Dialect) (sql.Result, error)

Insert has same functionality of ef's.

func (*Tx) Update

func (tx *Tx) Update(table string, tgt interface{}, optDialect ...dialect.Dialect) (sql.Result, error)

Update has same functionality of ef's.

Jump to

Keyboard shortcuts

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