quirk

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 18 Imported by: 3

Documentation

Index

Constants

View Source
const (
	Id        = "id"
	CreatedAt = "created_at"
	UpdatedAt = "updated_at"
	Vectors   = "vectors"
)
View Source
const (
	Default          = "DEFAULT"
	CurrentTimestamp = "CURRENT_TIMESTAMP"
)
View Source
const (
	Postgres = "postgres"
	Mysql    = "mysql"
)
View Source
const (
	ParamPrefix = "@"
	Placeholder = "?"
)

Variables

View Source
var (
	ErrorMismatchArgs = errors.New("placeholders and args count mismatch")
)

Functions

func CreateInsert added in v0.1.6

func CreateInsert(data map[string]any) (string, string)

func CreateTableStructure

func CreateTableStructure(fields []Field) string

func CreateUpdate added in v0.1.6

func CreateUpdate(data map[string]any) string

func MapToTsVectorsValue added in v0.1.7

func MapToTsVectorsValue[T any](m map[string]T) string

func Normalize added in v0.1.7

func Normalize(value string) string

func RemoveAccents added in v0.1.7

func RemoveAccents(value string) string

Types

type Config

type Config interface{}

func WithCertPath

func WithCertPath(certpath string) Config

func WithDbname

func WithDbname(dbname string) Config

func WithDriver

func WithDriver(driver string) Config

func WithHost

func WithHost(host string) Config

func WithLog

func WithLog(log bool) Config

func WithMysql

func WithMysql() Config

func WithPassword

func WithPassword(password string) Config

func WithPort

func WithPort(port int) Config

func WithPostgres

func WithPostgres() Config

func WithSsl

func WithSsl(sslmode string) Config

func WithSslAllow

func WithSslAllow() Config

func WithSslDisable

func WithSslDisable() Config

func WithSslPrefer

func WithSslPrefer() Config

func WithSslRequire

func WithSslRequire() Config

func WithSslVerifyCa

func WithSslVerifyCa() Config

func WithSslVerifyFull

func WithSslVerifyFull() Config

func WithUser

func WithUser(user string) Config

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

func Connect

func Connect(configs ...Config) (*DB, error)

func MustConnect added in v0.1.7

func MustConnect(configs ...Config) *DB

func Open

func Open(driverName, dataSourceName string) (*DB, error)

func (*DB) Begin

func (d *DB) Begin() (*DB, error)

func (*DB) Commit

func (d *DB) Commit() error

func (*DB) DriverName

func (d *DB) DriverName() string

func (*DB) Log

func (d *DB) Log(use ...bool)

func (*DB) MustBegin

func (d *DB) MustBegin() *DB

func (*DB) MustCommit

func (d *DB) MustCommit()

func (*DB) MustRollback

func (d *DB) MustRollback()

func (*DB) Q added in v0.1.8

func (d *DB) Q(query string, arg ...Map) *Quirk

func (*DB) Rollback

func (d *DB) Rollback() error

type Field

type Field struct {
	Name  string
	Props string
	Value any
}

func MergeFields

func MergeFields(a []Field, b []Field) []Field

type Jsonb added in v0.1.7

type Jsonb[T any] map[string]T

func MapToJsonb added in v0.1.7

func MapToJsonb[T any](mv map[string]T) Jsonb[T]

func (*Jsonb[T]) Scan added in v0.1.7

func (j *Jsonb[T]) Scan(value any) error

func (Jsonb[T]) Value added in v0.1.7

func (j Jsonb[T]) Value() (driver.Value, error)

type Map added in v0.1.6

type Map map[string]any

type Quirk

type Quirk struct {
	*DB
	// contains filtered or unexported fields
}

func New

func New(db *DB) *Quirk

func (*Quirk) CreateMatcher

func (q *Quirk) CreateMatcher() string

func (*Quirk) CreateSql

func (q *Quirk) CreateSql() string

func (*Quirk) Exec

func (q *Quirk) Exec(r ...any) error

func (*Quirk) If

func (q *Quirk) If(condition bool, query string, arg ...Map) *Quirk

func (*Quirk) MustExec

func (q *Quirk) MustExec(r ...any)

func (*Quirk) Q

func (q *Quirk) Q(query string, arg ...Map) *Quirk

func (*Quirk) Subscribe

func (q *Quirk) Subscribe(s subscription)

func (*Quirk) WhereExists added in v0.1.4

func (q *Quirk) WhereExists() bool

type Safe

type Safe struct {
	Value any
}

func CreateTsQuery

func CreateTsQuery(value string) Safe

func CreateTsVectors

func CreateTsVectors(values ...any) Safe

func (Safe) String added in v0.1.4

func (s Safe) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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