data_postgres

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 12 Imported by: 1

README

data-postgres

chefgo postgres data driver.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DRIVERS = []string{
		"postgresql", "postgres", "pgsql", "pgdb", "pg",
		"cockroachdb", "cockroach", "crdb",
		"timescaledb", "timescale", "tsdb",
	}
)
View Source
var (
	SCHEMAS = []string{
		"postgresql://",
		"postgres://",
		"pgsql://",
		"pgdb://",
		"cockroachdb://",
		"cockroach://",
		"crdb://",
		"timescale://",
		"timescaledb://",
		"tsdb://",
	}
)

Functions

func Driver

func Driver() data.Driver

返回驱动

Types

type PostgresBase

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

func (*PostgresBase) Batch

func (base *PostgresBase) Batch(next data.BatchFunc) Res

批量操作,包装事务

func (*PostgresBase) Begin

func (base *PostgresBase) Begin() (*sql.Tx, error)

开启手动模式

func (*PostgresBase) Break

func (base *PostgresBase) Break(key string)

删除ID生成器

func (*PostgresBase) Cancel

func (base *PostgresBase) Cancel() error

取消事务

func (*PostgresBase) Close

func (base *PostgresBase) Close() error

关闭数据库

func (*PostgresBase) Erred

func (base *PostgresBase) Erred() error

func (*PostgresBase) Model

func (base *PostgresBase) Model(name string) data.DataModel

获取模型对象

func (*PostgresBase) Serial

func (base *PostgresBase) Serial(key string, start, step int64) int64

ID生成器 序列版

func (*PostgresBase) Submit

func (base *PostgresBase) Submit() error

提交事务

func (*PostgresBase) Table

func (base *PostgresBase) Table(name string) data.DataTable

获取表对象

func (*PostgresBase) View

func (base *PostgresBase) View(name string) data.DataView

获取模型对象

type PostgresConnect

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

数据库连接

func (*PostgresConnect) Base

func (connect *PostgresConnect) Base() data.DataBase

func (*PostgresConnect) Close

func (connect *PostgresConnect) Close() error

关闭连接

func (*PostgresConnect) Health

func (connect *PostgresConnect) Health() (data.Health, error)

健康检查

func (*PostgresConnect) Open

func (connect *PostgresConnect) Open() error

打开连接

type PostgresDriver

type PostgresDriver struct{}

func (*PostgresDriver) Connect

func (drv *PostgresDriver) Connect(name string, config data.Config) (data.Connect, error)

驱动连接

type PostgresExecutor

type PostgresExecutor interface {
	Exec(query string, args ...Any) (sql.Result, error)
	Prepare(query string) (*sql.Stmt, error)
	Query(query string, args ...Any) (*sql.Rows, error)
	QueryRow(query string, args ...Any) *sql.Row
}

type PostgresModel

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

func (*PostgresModel) First

func (model *PostgresModel) First(args ...Any) Map

查询单条 应该不需要用MAP,直接写SQL的

func (*PostgresModel) Query

func (model *PostgresModel) Query(args ...Any) []Map

查询列表

type PostgresTable

type PostgresTable struct {
	PostgresView
}

func (*PostgresTable) Change

func (table *PostgresTable) Change(item Map, dddd Map) Map

修改对象

func (*PostgresTable) Create

func (table *PostgresTable) Create(dddd Map) Map

创建对象

func (*PostgresTable) Delete

func (table *PostgresTable) Delete(args ...Any) int64

批量删除,这可是真删

func (*PostgresTable) Remove

func (table *PostgresTable) Remove(args ...Any) Map

逻辑删除和恢复已经抛弃 这两个功能应该是逻辑层干的事,不应和驱动混在一起 此为物理删除单条记录,并返回记录,所以要先查询单条

func (*PostgresTable) Update

func (table *PostgresTable) Update(update Map, args ...Any) int64

批量更新,直接更了, 没有任何relate相关处理的

type PostgresView

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

func (*PostgresView) Count

func (view *PostgresView) Count(args ...Any) float64

统计数量 添加函数支持 函数(字段)

func (*PostgresView) Entity

func (view *PostgresView) Entity(id Any) Map

查询唯一对象 换成字段*版

func (*PostgresView) First

func (view *PostgresView) First(args ...Any) Map

查询单条 171015改成*版

func (*PostgresView) Group

func (view *PostgresView) Group(field string, args ...Any) []Map

查询分组

func (*PostgresView) Limit

func (view *PostgresView) Limit(offset, limit Any, args ...Any) (int64, []Map)

分页查询 171015更新为字段*版

func (*PostgresView) Query

func (view *PostgresView) Query(args ...Any) []Map

查询列表 171015改成*版

Jump to

Keyboard shortcuts

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