datastore

package
v0.0.0-...-ae0949c Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecContext

func ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

func Init

func Init(dsn string) error

func NamedExec

func NamedExec(query string, arg interface{}) (sql.Result, error)

func NamedQuery

func NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)

func QueryRow

func QueryRow(query string, args ...any) *sql.Row

func Select

func Select(dest interface{}, query string, args ...interface{}) error

func TypeToDbType

func TypeToDbType(fieldType string) string

Types

type ITable

type ITable[M any] interface {
	//NewModels() []*M
	GetConditions() []ModelCondition
}

type ModelCondition

type ModelCondition struct {
	//table       *Table[T, M]
	Name        string
	Type        string
	DbColumn    string
	DbType      string
	DbCondition string
	DbOperator  string
	Changed     bool
	Value       any
}

func NewCondition

func NewCondition(goName, goType, dbColumn, dbType string) ModelCondition

func (*ModelCondition) Eq

func (m *ModelCondition) Eq(value any) *ModelCondition

type Table

type Table[T ITable[M], M any] struct {
	TableName string
	// contains filtered or unexported fields
}

func NewTable

func NewTable[T ITable[M], M any](name string, schema T) Table[T, M]

func (*Table[T, M]) Count

func (t *Table[T, M]) Count() (int64, error)

func (*Table[T, M]) Get

func (t *Table[T, M]) Get(pk any) (*M, error)

func (*Table[T, M]) GetWhere

func (t *Table[T, M]) GetWhere(whereFunc func(m T)) (*M, error)

func (*Table[T, M]) GetWhereConditions

func (m *Table[T, M]) GetWhereConditions() []ModelCondition

func (*Table[T, M]) GetWhereParams

func (m *Table[T, M]) GetWhereParams() map[string]any

func (*Table[T, M]) Select

func (t *Table[T, M]) Select(offset, limit int) ([]M, error)

func (*Table[T, M]) SetTable

func (m *Table[T, M]) SetTable(table T)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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