db

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldType_String   = 1
	FieldType_Int      = 2
	FieldType_DATETIME = 3
)

Variables

View Source
var (
	ERROR_NOT_CONNECTION = errors.New("db not connection")
)
View Source
var ERROR_NOT_FOUND_RECORD = errors.New("NOT FOUND RECORD")

Functions

func Get

func Get() *connection

func InsertData

func InsertData(table string, data DataMap) (int64, error)

func UpdateData

func UpdateData(table string, saveData, whereDate DataMap) (int64, error)

Types

type DataMap

type DataMap map[string]interface{}

func SimpleQuery

func SimpleQuery(table string, field []string, whereMap DataMap) ([]DataMap, error)

type Fields

type Fields struct {
	FieldName   string      `json:"fieldName"`
	IsPrimary   bool        `json:"isPrimary"`
	DefaultData interface{} `json:"defaultData"`
	FieldType   int         `json:"dataType"` // 字段类型
}

type Table

type Table struct {
	sync.RWMutex
	TableName   string
	Fields      map[string]Fields
	PrimaryData DataMap
	ColumnData  DataMap
	IsLoading   bool
}

func NewTable

func NewTable(tableName string) *Table

func (*Table) AddColumn

func (this *Table) AddColumn(data []Fields)

func (*Table) Delete

func (this *Table) Delete(key DataMap)

func (*Table) Insert

func (this *Table) Insert(data DataMap) (int64, error)

func (*Table) PreColumn

func (this *Table) PreColumn(data DataMap) DataMap

func (*Table) Query

func (this *Table) Query() ([]DataMap, error)

*

一般条件  a= b  and  a=c

func (*Table) Record

func (this *Table) Record(key interface{}) (DataMap, error)

func (*Table) Save

func (this *Table) Save(data DataMap) (int64, error)

func (*Table) Update

func (this *Table) Update(data DataMap) (int64, error)

Jump to

Keyboard shortcuts

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