relationdbdao

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dao

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

func (*Dao) Begin

func (d *Dao) Begin(ctx context.Context) (*sql.Tx, error)

func (*Dao) Close

func (d *Dao) Close() error

func (*Dao) FetchValues

func (d *Dao) FetchValues(ctx context.Context, tableName string, keyConditions datamodels.Record, inField string, inValues []interface{}, valueField string) (map[string]interface{}, error)

func (*Dao) GetBuilder

func (d *Dao) GetBuilder() squirrel.StatementBuilderType

func (*Dao) GetDb

func (d *Dao) GetDb() *sql.DB

func (*Dao) MaxId

func (d *Dao) MaxId(ctx context.Context, tableName string, fieldName string) (int64, error)

func (*Dao) Ping

func (d *Dao) Ping(ctx context.Context) error

type IPrimaryDao

type IPrimaryDao interface {
	IReplicaDao
	Begin(ctx context.Context) (*sql.Tx, error)
	CreateTable(ctx context.Context, table string, cols []datamodels.Column) error
	AddColumns(ctx context.Context, table string, cols []datamodels.Column) error
	CreateForeignKey(ctx context.Context, table, col, refTable, refCol string) error
	CreateIndex(ctx context.Context, table string, fields []string, isUniq bool) error
	UpdateOnConflict(ctx context.Context, tableName string, data datamodels.Record, keyFields []string) (bool, error)
	BatchUpdateOnConflict(ctx context.Context, tableName string, records []datamodels.Record, keyFields []string) error
	Increase(ctx context.Context, tableName string, keyConditions datamodels.Record, valueField string, initVal, delta int64) (int64, error)
	RenameTable(ctx context.Context, oldName, newName string) error
	RenameColumn(ctx context.Context, table, oldName, newName string) error
	DropForeignKey(ctx context.Context, table, fkName string) error
}

func CreateDao

func CreateDao(provider descriptors.DatabaseProvider, connectionString string) (IPrimaryDao, error)

type IReplicaDao

type IReplicaDao interface {
	GetColumnDefinitions(ctx context.Context, table string) ([]datamodels.Column, error)
	FetchValues(ctx context.Context, tableName string, keyConditions datamodels.Record, inField string, inValues []interface{}, valueField string) (map[string]interface{}, error)
	MaxId(ctx context.Context, tableName string, fieldName string) (int64, error)
	CastDate(field string) string
	GetBuilder() squirrel.StatementBuilderType
	GetDb() *sql.DB
	Ping(ctx context.Context) error
	Close() error
}

type PostgresDao

type PostgresDao struct {
	Dao
}

func NewPostgresDao

func NewPostgresDao(connectionString string) (*PostgresDao, error)

func (*PostgresDao) AddColumns

func (d *PostgresDao) AddColumns(ctx context.Context, table string, cols []datamodels.Column) error

func (*PostgresDao) BatchUpdateOnConflict

func (d *PostgresDao) BatchUpdateOnConflict(ctx context.Context, tableName string, records []datamodels.Record, keyFields []string) error

func (*PostgresDao) CastDate

func (d *PostgresDao) CastDate(field string) string

func (*PostgresDao) CreateForeignKey

func (d *PostgresDao) CreateForeignKey(ctx context.Context, table, col, refTable, refCol string) error

func (*PostgresDao) CreateIndex

func (d *PostgresDao) CreateIndex(ctx context.Context, table string, fields []string, isUniq bool) error

func (*PostgresDao) CreateTable

func (d *PostgresDao) CreateTable(ctx context.Context, table string, cols []datamodels.Column) error

func (*PostgresDao) DropForeignKey

func (d *PostgresDao) DropForeignKey(ctx context.Context, table, fkName string) error

func (*PostgresDao) FetchValues

func (d *PostgresDao) FetchValues(ctx context.Context, tableName string, keyConditions datamodels.Record, inField string, inValues []interface{}, valueField string) (map[string]interface{}, error)

func (*PostgresDao) GetColumnDefinitions

func (d *PostgresDao) GetColumnDefinitions(ctx context.Context, table string) ([]datamodels.Column, error)

func (*PostgresDao) Increase

func (d *PostgresDao) Increase(ctx context.Context, tableName string, keyConditions datamodels.Record, valueField string, initVal, delta int64) (int64, error)

func (*PostgresDao) MaxId

func (d *PostgresDao) MaxId(ctx context.Context, tableName string, fieldName string) (int64, error)

func (*PostgresDao) RenameColumn

func (d *PostgresDao) RenameColumn(ctx context.Context, table, oldName, newName string) error

func (*PostgresDao) RenameTable

func (d *PostgresDao) RenameTable(ctx context.Context, oldName, newName string) error

func (*PostgresDao) UpdateOnConflict

func (d *PostgresDao) UpdateOnConflict(ctx context.Context, tableName string, data datamodels.Record, keyFields []string) (bool, error)

type SqliteDao

type SqliteDao struct {
	Dao
}

func NewSqliteDao

func NewSqliteDao(connectionString string) (*SqliteDao, error)

func (*SqliteDao) AddColumns

func (d *SqliteDao) AddColumns(ctx context.Context, table string, cols []datamodels.Column) error

func (*SqliteDao) BatchUpdateOnConflict

func (d *SqliteDao) BatchUpdateOnConflict(ctx context.Context, tableName string, records []datamodels.Record, keyFields []string) error

func (*SqliteDao) CastDate

func (d *SqliteDao) CastDate(field string) string

func (*SqliteDao) CreateForeignKey

func (d *SqliteDao) CreateForeignKey(ctx context.Context, table, col, refTable, refCol string) error

func (*SqliteDao) CreateIndex

func (d *SqliteDao) CreateIndex(ctx context.Context, table string, fields []string, isUniq bool) error

func (*SqliteDao) CreateTable

func (d *SqliteDao) CreateTable(ctx context.Context, table string, cols []datamodels.Column) error

func (*SqliteDao) DropForeignKey

func (d *SqliteDao) DropForeignKey(ctx context.Context, table, fkName string) error

func (*SqliteDao) FetchValues

func (d *SqliteDao) FetchValues(ctx context.Context, tableName string, keyConditions datamodels.Record, inField string, inValues []interface{}, valueField string) (map[string]interface{}, error)

func (*SqliteDao) GetColumnDefinitions

func (d *SqliteDao) GetColumnDefinitions(ctx context.Context, table string) ([]datamodels.Column, error)

func (*SqliteDao) Increase

func (d *SqliteDao) Increase(ctx context.Context, tableName string, keyConditions datamodels.Record, valueField string, initVal, delta int64) (int64, error)

func (*SqliteDao) MaxId

func (d *SqliteDao) MaxId(ctx context.Context, tableName string, fieldName string) (int64, error)

func (*SqliteDao) RenameColumn

func (d *SqliteDao) RenameColumn(ctx context.Context, table, oldName, newName string) error

func (*SqliteDao) RenameTable

func (d *SqliteDao) RenameTable(ctx context.Context, oldName, newName string) error

func (*SqliteDao) UpdateOnConflict

func (d *SqliteDao) UpdateOnConflict(ctx context.Context, tableName string, data datamodels.Record, keyFields []string) (bool, error)

Jump to

Keyboard shortcuts

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