db

package
v0.0.0-...-0e6b51b Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(rs *sql.Rows, db Database, table string, uniqueKeys ...string) error

func Count

func Count(db Database, object IObject, prefix string, sql string, args ...interface{}) (int64, error)

func Delete

func Delete(db Database, object IObject, prefix string) (sql.Result, error)

func DeleteWithSQL

func DeleteWithSQL(db Database, object IObject, prefix string, sql string, args ...interface{}) (sql.Result, error)

func Each

func Each(object interface{}, fn func(field Field) bool) bool

func Insert

func Insert(db Database, object IObject, prefix string) (sql.Result, error)

func Install

func Install(db Database, object IObject, prefix string, autoIncrement int64, table interface{}) (error, interface{})

func InstallSQL

func InstallSQL(table interface{}, prefix string, autoIncrement int64, ver interface{}) (string, interface{})

func Merge

func Merge(options ...interface{}) interface{}

func Query

func Query(db Database, object IObject, prefix string, sql string, args ...interface{}) (*sql.Rows, error)

func QueryWithKeys

func QueryWithKeys(db Database, object IObject, prefix string, keys map[string]bool, sql string, args ...interface{}) (*sql.Rows, error)

func TableName

func TableName(prefix string, object IObject) string

func Transaction

func Transaction(db *sql.DB, fn func(conn Database) error) error

func Update

func Update(db Database, object IObject, prefix string) (sql.Result, error)

func UpdateWithKeys

func UpdateWithKeys(db Database, object IObject, prefix string, keys map[string]bool) (sql.Result, error)

Types

type Database

type Database interface {
	Query(query string, args ...interface{}) (*sql.Rows, error)
	Exec(query string, args ...interface{}) (sql.Result, error)
}

type Field

type Field struct {
	F            reflect.StructField `json:"-"`
	V            reflect.Value       `json:"-"`
	Name         string              `json:"name"`
	IsObject     bool                `json:"-"`
	IsJSONObject bool                `json:"-"`
}

type IObject

type IObject interface {
	GetTitle() string
	GetName() string
	GetId() int64
	SetId(id int64)
}

func Get

func Get(db Database, object IObject, prefix string, sql string, args ...interface{}) (IObject, error)

type Object

type Object struct {
	Id int64 `json:"id" title:"ID"`
}

func (*Object) GetId

func (O *Object) GetId() int64

func (*Object) GetName

func (O *Object) GetName() string

func (*Object) GetTitle

func (O *Object) GetTitle() string

func (*Object) SetId

func (O *Object) SetId(id int64)

type Scaner

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

func NewScaner

func NewScaner(object interface{}) *Scaner

func (*Scaner) Scan

func (o *Scaner) Scan(rows *sql.Rows) error

Jump to

Keyboard shortcuts

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