Merge pull request #4 from oinume/feature/softdelete
Add softdelete feature
This commit is contained in:
commit
3e0fa232ab
|
@ -27,6 +27,7 @@ type Column struct {
|
|||
MapType int
|
||||
IsCreated bool
|
||||
IsUpdated bool
|
||||
IsDeleted bool
|
||||
IsCascade bool
|
||||
IsVersion bool
|
||||
fieldPath []string
|
||||
|
@ -50,6 +51,7 @@ func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int, nullable
|
|||
MapType: TWOSIDES,
|
||||
IsCreated: false,
|
||||
IsUpdated: false,
|
||||
IsDeleted: false,
|
||||
IsCascade: false,
|
||||
IsVersion: false,
|
||||
fieldPath: nil,
|
||||
|
|
8
table.go
8
table.go
|
@ -17,6 +17,7 @@ type Table struct {
|
|||
AutoIncrement string
|
||||
Created map[string]bool
|
||||
Updated string
|
||||
Deleted string
|
||||
Version string
|
||||
Cacher Cacher
|
||||
StoreEngine string
|
||||
|
@ -83,6 +84,10 @@ func (table *Table) UpdatedColumn() *Column {
|
|||
return table.GetColumn(table.Updated)
|
||||
}
|
||||
|
||||
func (table *Table) DeletedColumn() *Column {
|
||||
return table.GetColumn(table.Deleted)
|
||||
}
|
||||
|
||||
// add a column to table
|
||||
func (table *Table) AddColumn(col *Column) {
|
||||
table.columnsSeq = append(table.columnsSeq, col.Name)
|
||||
|
@ -106,6 +111,9 @@ func (table *Table) AddColumn(col *Column) {
|
|||
if col.IsUpdated {
|
||||
table.Updated = col.Name
|
||||
}
|
||||
if col.IsDeleted {
|
||||
table.Deleted = col.Name
|
||||
}
|
||||
if col.IsVersion {
|
||||
table.Version = col.Name
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue