sqlbee_go

package module
v0.0.0-...-8645879 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: MIT Imports: 11 Imported by: 0

README

sqlbee

sqlbee logo

a simple sql package for golang.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JsonToMap

func JsonToMap(jsonStr string) (map[string]any, error)

func SqlBeeInstance

func SqlBeeInstance() (*sql.DB, error)

连接数据库的实例

func SqlBee_ScanToMapBag

func SqlBee_ScanToMapBag[T any](_rows *sql.Rows, _struct T) []map[string]any

将数据库读取的rows scan 到一个map的bag里

需要传入一个对应数据类型的struct

Types

type SqlBeeCommon

type SqlBeeCommon struct {
	SqlBeeHelper
	Table     string
	Model     any
	Filter    map[string]any
	RunStatus bool //是否run()过?
}

层次结构为:

SqlBeeHelper -> SqlBeeCommon -> SqlBee[?]

type SqlBeeE

type SqlBeeE struct {
	SqlBeeCommon
	Method        SqlBeeE_MethodType
	Insert_values map[string]any
	Insert_lastId int //插入操作之后返回的新数据条的id
	Update_values map[string]any
	Update_ids    []int //更新操作之后返回的受影响的所有数据条的id
}

type SqlBeeE_MethodType

type SqlBeeE_MethodType int

SqlBeeE的method type (枚举)

const (
	// 第一个元素为None
	None SqlBeeE_MethodType = iota
	Insert
	Delete
	Update
)

type SqlBeeHelper

type SqlBeeHelper struct {
}

层次结构为:

SqlBeeHelper -> SqlBeeCommon -> SqlBee[?]

SqlBeeHelper是最顶层的配置

func (*SqlBeeHelper) SQL_Semantics_WHERE

func (r *SqlBeeHelper) SQL_Semantics_WHERE(_filter map[string]any) string

为 WHERE 解析语义(包含WHERE关键词本身)

返回例如 " WHERE name = '张三' AND city = 'Shanghai' "

type SqlBeeQ

type SqlBeeQ struct {
	SqlBeeCommon
	Order_by string
	Limit    int
}

Jump to

Keyboard shortcuts

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