Documentation
¶
Index ¶
- Variables
- type ColumnDef
- func (c *ColumnDef) Check(expr string) *ColumnDef
- func (c *ColumnDef) Collate(name string) *ColumnDef
- func (c *ColumnDef) Default(v any) *ColumnDef
- func (c *ColumnDef) DefaultExpr(expr string) *ColumnDef
- func (c *ColumnDef) GeneratedAs(expr string) *ColumnDef
- func (c *ColumnDef) Identity() *ColumnDef
- func (c *ColumnDef) Index() *ColumnDef
- func (c *ColumnDef) NotNull() *ColumnDef
- func (c *ColumnDef) OnDelete(a ReferentialAction) *ColumnDef
- func (c *ColumnDef) OnUpdate(a ReferentialAction) *ColumnDef
- func (c *ColumnDef) PrimaryKey() *ColumnDef
- func (c *ColumnDef) References(col *ColumnDef) *ColumnDef
- func (c *ColumnDef) Str() string
- func (c *ColumnDef) String() string
- func (c *ColumnDef) Unique() *ColumnDef
- type ColumnType
- func Array(inner *ColumnType) *ColumnType
- func BigInt() *ColumnType
- func BigSerial() *ColumnType
- func Bool() *ColumnType
- func Bytea() *ColumnType
- func Char(length int) *ColumnType
- func Date() *ColumnType
- func Double() *ColumnType
- func Enum(name string, values ...string) *ColumnType
- func Int() *ColumnType
- func Interval() *ColumnType
- func JSONB() *ColumnType
- func Money() *ColumnType
- func Numeric(precision, scale int) *ColumnType
- func Real() *ColumnType
- func Serial() *ColumnType
- func SmallInt() *ColumnType
- func SmallSerial() *ColumnType
- func Text() *ColumnType
- func Time() *ColumnType
- func Timestamp() *ColumnType
- func TimestampTZ() *ColumnType
- func Timetz() *ColumnType
- func UUID() *ColumnType
- func Varchar(length int) *ColumnType
- type ConstraintDef
- type IndexDef
- type ReferentialAction
- type TableDef
- func (t *TableDef) Col(name string) *ColumnDef
- func (t *TableDef) Columns() []*ColumnDef
- func (t *TableDef) Constraint(name, expr string) *TableDef
- func (t *TableDef) GetConstraints() []ConstraintDef
- func (t *TableDef) GetIndices() []IndexDef
- func (t *TableDef) GetUnique() []IndexDef
- func (t *TableDef) Index(name string, cols ...string) *TableDef
- func (t *TableDef) IndexPartial(name string, cols []string, predicate string) *TableDef
- func (t *TableDef) IndexUnique(name string, cols ...string) *TableDef
- func (t *TableDef) TableName() string
- func (t *TableDef) Unique(name string, cols ...string) *TableDef
Constants ¶
This section is empty.
Variables ¶
View Source
var EnumRegistry = map[string]*ColumnType{}
View Source
var Registry []*TableDef
Functions ¶
This section is empty.
Types ¶
type ColumnDef ¶
type ColumnDef struct {
Table string
Name string
Type *ColumnType
IsPK bool
IsNotNull bool
IsUnique bool
IsIdentity bool
DefaultVal any
DefaultExprStr string
GeneratedExpr string
CheckExpr string
Collation string
RefCol *ColumnDef
OnDeleteAction ReferentialAction
OnUpdateAction ReferentialAction
HasIndex bool
}
func Column ¶
func Column(name string, t *ColumnType) *ColumnDef
func (*ColumnDef) DefaultExpr ¶
func (*ColumnDef) GeneratedAs ¶ added in v0.1.3
func (*ColumnDef) OnDelete ¶
func (c *ColumnDef) OnDelete(a ReferentialAction) *ColumnDef
func (*ColumnDef) OnUpdate ¶
func (c *ColumnDef) OnUpdate(a ReferentialAction) *ColumnDef
func (*ColumnDef) PrimaryKey ¶
func (*ColumnDef) References ¶
type ColumnType ¶
func Array ¶ added in v0.1.3
func Array(inner *ColumnType) *ColumnType
Array wraps the inner type as a PostgreSQL one-dimensional array, e.g. Array(Int()) renders as INTEGER[].
func BigInt ¶
func BigInt() *ColumnType
func BigSerial ¶
func BigSerial() *ColumnType
func Bool ¶
func Bool() *ColumnType
func Bytea ¶ added in v0.1.3
func Bytea() *ColumnType
func Char ¶ added in v0.1.3
func Char(length int) *ColumnType
func Date ¶ added in v0.1.3
func Date() *ColumnType
func Double ¶ added in v0.1.3
func Double() *ColumnType
func Enum ¶
func Enum(name string, values ...string) *ColumnType
func Int ¶
func Int() *ColumnType
func Interval ¶ added in v0.1.3
func Interval() *ColumnType
func JSONB ¶
func JSONB() *ColumnType
func Money ¶ added in v0.1.3
func Money() *ColumnType
func Numeric ¶
func Numeric(precision, scale int) *ColumnType
func Real ¶ added in v0.1.3
func Real() *ColumnType
func Serial ¶
func Serial() *ColumnType
func SmallInt ¶ added in v0.1.3
func SmallInt() *ColumnType
func SmallSerial ¶ added in v0.1.3
func SmallSerial() *ColumnType
func Text ¶
func Text() *ColumnType
func Time ¶ added in v0.1.3
func Time() *ColumnType
func Timestamp ¶
func Timestamp() *ColumnType
func TimestampTZ ¶
func TimestampTZ() *ColumnType
func Timetz ¶ added in v0.1.3
func Timetz() *ColumnType
func UUID ¶
func UUID() *ColumnType
func Varchar ¶
func Varchar(length int) *ColumnType
type ConstraintDef ¶ added in v0.1.3
type ReferentialAction ¶
type ReferentialAction string
const ( Cascade ReferentialAction = "CASCADE" SetNull ReferentialAction = "SET NULL" Restrict ReferentialAction = "RESTRICT" NoAction ReferentialAction = "NO ACTION" )
type TableDef ¶
type TableDef struct {
Name string
// contains filtered or unexported fields
}
func (*TableDef) Constraint ¶ added in v0.1.3
func (*TableDef) GetConstraints ¶ added in v0.1.3
func (t *TableDef) GetConstraints() []ConstraintDef
func (*TableDef) GetIndices ¶
func (*TableDef) IndexPartial ¶ added in v0.1.3
IndexPartial creates an index restricted to rows matching the predicate, e.g. IndexPartial("idx_users_active", []string{"status"}, "status = 'active'").
func (*TableDef) IndexUnique ¶ added in v0.1.3
Click to show internal directories.
Click to hide internal directories.