pgsql

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

View Source
const TimestampFormat = "YYYY-MM-DD hh:mm:ss"

Variables

View Source
var ALL = all{}
View Source
var Bool = &_Bool{}
View Source
var Int = &_Int{}

Functions

func NullAble

func NullAble[V any](ft Type[V]) nullAble[V]

func SELECT

func SELECT(table TABLE, fields ...SQLer) *_Select

func Unique

func Unique[V any](ft Type[V]) unique[V]

Types

type BOOL

type BOOL = FIELD[bool]

type BigInt

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

bigint

func (BigInt) Escape

func (v BigInt) Escape(val int) string

func (BigInt) GeneratedAlwaysAsID

func (v BigInt) GeneratedAlwaysAsID() Type[int]

func (BigInt) GeneratedByDefaultAsID

func (v BigInt) GeneratedByDefaultAsID() Type[int]

func (BigInt) SQL

func (v BigInt) SQL() string

type Create

type Create struct {
	Table  TABLE
	Fields []_createFields
}

func CREATE

func CREATE(table TABLE, fields ..._createFields) *Create

func (*Create) SQL

func (c *Create) SQL() string

func (*Create) String

func (c *Create) String() string

type Date

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

func (Date) Escape

func (v Date) Escape(val time.Time) string

func (Date) IsNullAble

func (v Date) IsNullAble() bool

func (Date) IsUnique

func (v Date) IsUnique() bool

func (Date) SQL

func (v Date) SQL() string

type Delete

type Delete struct {
	Table TABLE
	// contains filtered or unexported fields
}

func DELETE

func DELETE(table TABLE) *Delete

func (*Delete) SQL

func (c *Delete) SQL() string

func (*Delete) String

func (c *Delete) String() string

func (*Delete) WHERE

func (s *Delete) WHERE(where SQLer) *Delete

type Dollar

type Dollar int

func (Dollar) SQL

func (d Dollar) SQL() string

func (Dollar) ValueToSQL

func (d Dollar) ValueToSQL(pos int) string

type FIELD

type FIELD[V any] struct {
	Name         string
	Table        TABLE
	Reference    *FIELD[V]
	IsPrimaryKey bool
	Description  string
	Type         Type[V]
	value.Var[V]
	Target *V
}

func Field

func Field[V any](t TABLE, name string, tp Type[V]) FIELD[V]

func (FIELD[V]) As

func (f FIELD[V]) As(name string) SQL

func (FIELD[V]) AsPrimaryKey

func (f FIELD[V]) AsPrimaryKey() FIELD[V]

func (FIELD[V]) CreationSQL

func (f FIELD[V]) CreationSQL() string

func (*FIELD[V]) GetTarget

func (c *FIELD[V]) GetTarget() any

func (FIELD[V]) InnerJoin

func (c FIELD[V]) InnerJoin(joinField FIELD[V]) Join

func (FIELD[V]) InnerJoinAlias

func (c FIELD[V]) InnerJoinAlias(joinField FIELD[V], alias string) Join

func (FIELD[V]) Is

func (f FIELD[V]) Is(value V) where

func (FIELD[V]) IsEqualOrGreaterThan

func (f FIELD[V]) IsEqualOrGreaterThan(value V) where

func (FIELD[V]) IsEqualOrLessThan

func (f FIELD[V]) IsEqualOrLessThan(value V) where

func (FIELD[V]) IsGreaterThan

func (f FIELD[V]) IsGreaterThan(value V) where

func (FIELD[V]) IsIn

func (f FIELD[V]) IsIn(value SQLer) where

func (FIELD[V]) IsLessThan

func (f FIELD[V]) IsLessThan(value V) where

func (FIELD[V]) IsNot

func (f FIELD[V]) IsNot(value V) where

func (FIELD[V]) OuterJoin

func (c FIELD[V]) OuterJoin(joinField FIELD[V]) Join

func (FIELD[V]) OuterJoinAlias

func (c FIELD[V]) OuterJoinAlias(joinField FIELD[V], alias string) Join

func (FIELD[V]) SQL

func (f FIELD[V]) SQL() string

func (*FIELD[V]) Set

func (f *FIELD[V]) Set(val V) *FIELD[V]

func (*FIELD[V]) SetTarget

func (f *FIELD[V]) SetTarget(valTarget *V) *FIELD[V]

func (*FIELD[V]) SetWithName

func (f *FIELD[V]) SetWithName(val V)

func (FIELD[V]) ValueToSQL

func (f FIELD[V]) ValueToSQL(pos int) string

func (FIELD[V]) WithDescription

func (f FIELD[V]) WithDescription(descr string) FIELD[V]

func (FIELD[V]) WithReference

func (f FIELD[V]) WithReference(ref FIELD[V]) FIELD[V]

type FLOAT

type FLOAT = FIELD[float64]

type Float

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

func (Float) Escape

func (v Float) Escape(val float64) string

func (Float) IsNullAble

func (v Float) IsNullAble() bool

func (Float) IsUnique

func (v Float) IsUnique() bool

func (Float) SQL

func (v Float) SQL() string

type INT

type INT = FIELD[int]

type Insert

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

func INSERT

func INSERT(table TABLE, fields ..._insertFields) *Insert

func (*Insert) SQL

func (c *Insert) SQL() string

func (*Insert) String

func (c *Insert) String() string

type JSONB

type JSONB struct{ VarChar }

func (JSONB) SQL

func (v JSONB) SQL() string

type Join

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

type Numeric

type Numeric [2]int

NUMERIC(precision, scale) decimal is the same as numeric

func (Numeric) Escape

func (v Numeric) Escape(val float64) string

func (Numeric) IsNullAble

func (v Numeric) IsNullAble() bool

func (Numeric) IsUnique

func (v Numeric) IsUnique() bool

func (Numeric) Precision

func (v Numeric) Precision() int

func (Numeric) SQL

func (v Numeric) SQL() string

func (Numeric) Scale

func (v Numeric) Scale() int

type Real

type Real struct{ Float }

real

func (Real) IsNullAble

func (v Real) IsNullAble() bool

func (Real) IsUnique

func (v Real) IsUnique() bool

func (Real) SQL

func (v Real) SQL() string

type SQL

type SQL string

func AND

func AND(wheres ...SQLer) SQL

func OR

func OR(wheres ...SQLer) SQL

func (SQL) SQL

func (s SQL) SQL() string

type SQLer

type SQLer interface {
	SQL() string
}

type STRING

type STRING = FIELD[string]

type Scanner

type Scanner interface {
	Err() error
	Next() bool
}

type Seq

type Seq[V any] interface {
	Each() iter.Seq[V]
	Err() error
}

func Each

func Each[V any](vl *V, sc Scanner, err error) Seq[V]

type SmallInt

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

smallint

func (SmallInt) Escape

func (v SmallInt) Escape(val int) string

func (SmallInt) GeneratedAlwaysAsID

func (v SmallInt) GeneratedAlwaysAsID() Type[int]

func (SmallInt) GeneratedByDefaultAsID

func (v SmallInt) GeneratedByDefaultAsID() Type[int]

func (SmallInt) SQL

func (v SmallInt) SQL() string

type TABLE

type TABLE struct {
	Name string
	// contains filtered or unexported fields
}

func (*TABLE) New

func (t *TABLE) New()

func (TABLE) SQL

func (t TABLE) SQL() string

func (*TABLE) SetName

func (t *TABLE) SetName(name string)

type TIME

type TIME = FIELD[time.Time]

type Text

type Text struct{ VarChar }

func (Text) SQL

func (v Text) SQL() string

type Timestamp

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

func (Timestamp) DefaultCurrent

func (v Timestamp) DefaultCurrent() Type[time.Time]

func (Timestamp) Escape

func (v Timestamp) Escape(val time.Time) string

func (Timestamp) IsNullAble

func (v Timestamp) IsNullAble() bool

func (Timestamp) IsUnique

func (v Timestamp) IsUnique() bool

func (Timestamp) SQL

func (v Timestamp) SQL() string

type TimestampTZ

type TimestampTZ struct{ Timestamp }

func (TimestampTZ) IsNullAble

func (v TimestampTZ) IsNullAble() bool

func (TimestampTZ) IsUnique

func (v TimestampTZ) IsUnique() bool

func (TimestampTZ) SQL

func (v TimestampTZ) SQL() string

type Type

type Type[V any] interface {
	SQL() string
	Escape(val V) string
	IsNullAble() bool
	IsUnique() bool
}

func Default

func Default[V any](def string, tp Type[V]) Type[V]

type UUID

type UUID struct{ VarChar }

func (UUID) DefaultRandom

func (v UUID) DefaultRandom() Type[string]

func (UUID) SQL

func (v UUID) SQL() string

type Update

type Update struct {
	Table  TABLE
	Fields []_insertFields
	// contains filtered or unexported fields
}

func UPDATE

func UPDATE(table TABLE, fields ..._insertFields) *Update

func (*Update) SQL

func (c *Update) SQL() string

func (*Update) String

func (c *Update) String() string

func (*Update) WHERE

func (s *Update) WHERE(where SQLer) *Update

type VarChar

type VarChar int

func (VarChar) Escape

func (v VarChar) Escape(val string) string

func (VarChar) IsNullAble

func (v VarChar) IsNullAble() bool

func (VarChar) IsUnique

func (v VarChar) IsUnique() bool

func (VarChar) SQL

func (v VarChar) SQL() string

Jump to

Keyboard shortcuts

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