Merge pull request #4 from oinume/feature/softdelete

Add softdelete feature
This commit is contained in:
Lunny Xiao 2014-11-05 15:39:11 +08:00
commit 3e0fa232ab
2 changed files with 10 additions and 0 deletions

View File

@ -27,6 +27,7 @@ type Column struct {
MapType int MapType int
IsCreated bool IsCreated bool
IsUpdated bool IsUpdated bool
IsDeleted bool
IsCascade bool IsCascade bool
IsVersion bool IsVersion bool
fieldPath []string fieldPath []string
@ -50,6 +51,7 @@ func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int, nullable
MapType: TWOSIDES, MapType: TWOSIDES,
IsCreated: false, IsCreated: false,
IsUpdated: false, IsUpdated: false,
IsDeleted: false,
IsCascade: false, IsCascade: false,
IsVersion: false, IsVersion: false,
fieldPath: nil, fieldPath: nil,

View File

@ -17,6 +17,7 @@ type Table struct {
AutoIncrement string AutoIncrement string
Created map[string]bool Created map[string]bool
Updated string Updated string
Deleted string
Version string Version string
Cacher Cacher Cacher Cacher
StoreEngine string StoreEngine string
@ -83,6 +84,10 @@ func (table *Table) UpdatedColumn() *Column {
return table.GetColumn(table.Updated) return table.GetColumn(table.Updated)
} }
func (table *Table) DeletedColumn() *Column {
return table.GetColumn(table.Deleted)
}
// 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)
@ -106,6 +111,9 @@ func (table *Table) AddColumn(col *Column) {
if col.IsUpdated { if col.IsUpdated {
table.Updated = col.Name table.Updated = col.Name
} }
if col.IsDeleted {
table.Deleted = col.Name
}
if col.IsVersion { if col.IsVersion {
table.Version = col.Name table.Version = col.Name
} }