Documentation
¶
Index ¶
- Constants
- type OptionSetterFn
- func As(as string) OptionSetterFn
- func AuditFields(enabled bool) OptionSetterFn
- func AutoIncrement(ai bool) OptionSetterFn
- func Columns(cols ...string) OptionSetterFn
- func CreatedAtColumn(col string) OptionSetterFn
- func CreatedByColumn(col string) OptionSetterFn
- func FromModelRef(m interface{}) OptionSetterFn
- func PrimaryKey(pk string) OptionSetterFn
- func SoftDelete(enabled bool) OptionSetterFn
- func SoftDeleteColumn(col string) OptionSetterFn
- func TableName(s string) OptionSetterFn
- func UpdatedAtColumn(col string) OptionSetterFn
- func UpdatedByColumn(col string) OptionSetterFn
- type Reference
- type Schema
- func (s *Schema) As() string
- func (s *Schema) AuditFields() bool
- func (s *Schema) AutoIncrement() bool
- func (s *Schema) Columns() []string
- func (s *Schema) CountColumns() int
- func (s *Schema) CreatedAtColumn() string
- func (s *Schema) CreatedByColumn() string
- func (s *Schema) Filter(column1 string, columnN ...string) []string
- func (s *Schema) InsertColumns() []string
- func (s *Schema) IsColumnExist(col string) bool
- func (s *Schema) PrimaryKey() string
- func (s *Schema) Ref() Reference
- func (s *Schema) SoftDelete() bool
- func (s *Schema) SoftDeleteColumn() string
- func (s *Schema) TableName() string
- func (s *Schema) UpdateColumns() []string
- func (s *Schema) UpdatedAtColumn() string
- func (s *Schema) UpdatedByColumn() string
Constants ¶
const ( DbTag = "db" SkipField = "-" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OptionSetterFn ¶
type OptionSetterFn func(*options)
func As ¶
func As(as string) OptionSetterFn
As set table alias to schema, will be use as reference if set
func AuditFields ¶
func AuditFields(enabled bool) OptionSetterFn
AuditFields enable/disable audit fields for schema
func AutoIncrement ¶
func AutoIncrement(ai bool) OptionSetterFn
AutoIncrement set auto increment options that will affect insert query generator
func CreatedAtColumn ¶
func CreatedAtColumn(col string) OptionSetterFn
CreatedAtColumn set custom column name for created_at (default: "created_at")
func CreatedByColumn ¶
func CreatedByColumn(col string) OptionSetterFn
CreatedByColumn set custom column name for created_by (default: "created_by")
func FromModelRef ¶
func FromModelRef(m interface{}) OptionSetterFn
FromModelRef reflect referenced model as Schema
func PrimaryKey ¶
func PrimaryKey(pk string) OptionSetterFn
PrimaryKey set columns that will be primary key, otherwise it will use "id" column
func SoftDelete ¶
func SoftDelete(enabled bool) OptionSetterFn
SoftDelete enable/disable soft delete for schema
func SoftDeleteColumn ¶
func SoftDeleteColumn(col string) OptionSetterFn
SoftDeleteColumn set custom column name for soft delete (default: "deleted_at")
func UpdatedAtColumn ¶
func UpdatedAtColumn(col string) OptionSetterFn
UpdatedAtColumn set custom column name for updated_at (default: "updated_at")
func UpdatedByColumn ¶
func UpdatedByColumn(col string) OptionSetterFn
UpdatedByColumn set custom column name for updated_by (default: "updated_by")
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
func New ¶
func New(args ...OptionSetterFn) *Schema
func (*Schema) AuditFields ¶
AuditFields returns whether audit fields are enabled for this schema
func (*Schema) AutoIncrement ¶
func (*Schema) CountColumns ¶
func (*Schema) CreatedAtColumn ¶
CreatedAtColumn returns the column name for created_at
func (*Schema) CreatedByColumn ¶
CreatedByColumn returns the column name for created_by
func (*Schema) InsertColumns ¶
func (*Schema) IsColumnExist ¶
func (*Schema) PrimaryKey ¶
func (*Schema) SoftDelete ¶
SoftDelete returns whether soft delete is enabled for this schema
func (*Schema) SoftDeleteColumn ¶
SoftDeleteColumn returns the column name used for soft delete
func (*Schema) UpdateColumns ¶
func (*Schema) UpdatedAtColumn ¶
UpdatedAtColumn returns the column name for updated_at
func (*Schema) UpdatedByColumn ¶
UpdatedByColumn returns the column name for updated_by