Add softdelete feature
This commit is contained in:
parent
c7420dd938
commit
dabc882406
|
@ -29,6 +29,7 @@ type Column struct {
|
||||||
IsUpdated bool
|
IsUpdated bool
|
||||||
IsCascade bool
|
IsCascade bool
|
||||||
IsVersion bool
|
IsVersion bool
|
||||||
|
IsSoftDelete bool
|
||||||
fieldPath []string
|
fieldPath []string
|
||||||
DefaultIsEmpty bool
|
DefaultIsEmpty bool
|
||||||
EnumOptions map[string]int
|
EnumOptions map[string]int
|
||||||
|
@ -52,6 +53,7 @@ func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int, nullable
|
||||||
IsUpdated: false,
|
IsUpdated: false,
|
||||||
IsCascade: false,
|
IsCascade: false,
|
||||||
IsVersion: false,
|
IsVersion: false,
|
||||||
|
IsSoftDelete: false,
|
||||||
fieldPath: nil,
|
fieldPath: nil,
|
||||||
DefaultIsEmpty: false,
|
DefaultIsEmpty: false,
|
||||||
EnumOptions: make(map[string]int),
|
EnumOptions: make(map[string]int),
|
||||||
|
|
8
table.go
8
table.go
|
@ -18,6 +18,7 @@ type Table struct {
|
||||||
Created map[string]bool
|
Created map[string]bool
|
||||||
Updated string
|
Updated string
|
||||||
Version string
|
Version string
|
||||||
|
SoftDelete string
|
||||||
Cacher Cacher
|
Cacher Cacher
|
||||||
StoreEngine string
|
StoreEngine string
|
||||||
Charset string
|
Charset string
|
||||||
|
@ -83,6 +84,10 @@ func (table *Table) UpdatedColumn() *Column {
|
||||||
return table.GetColumn(table.Updated)
|
return table.GetColumn(table.Updated)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (table *Table) SoftDeleteColumn() *Column {
|
||||||
|
return table.GetColumn(table.SoftDelete)
|
||||||
|
}
|
||||||
|
|
||||||
// add a column to table
|
// add a column to table
|
||||||
func (table *Table) AddColumn(col *Column) {
|
func (table *Table) AddColumn(col *Column) {
|
||||||
table.columnsSeq = append(table.columnsSeq, col.Name)
|
table.columnsSeq = append(table.columnsSeq, col.Name)
|
||||||
|
@ -109,6 +114,9 @@ func (table *Table) AddColumn(col *Column) {
|
||||||
if col.IsVersion {
|
if col.IsVersion {
|
||||||
table.Version = col.Name
|
table.Version = col.Name
|
||||||
}
|
}
|
||||||
|
if col.IsSoftDelete {
|
||||||
|
table.SoftDelete = col.Name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add an index or an unique to table
|
// add an index or an unique to table
|
||||||
|
|
Loading…
Reference in New Issue