github.com/octohelm/storage@v0.0.0-20240516030302-1ac2cc1ea347/pkg/dal/feature.go (about) 1 package dal 2 3 func IncludeAllRecord() func(m featureSettings) { 4 return func(m featureSettings) { 5 m.SetSoftDelete(false) 6 } 7 } 8 9 func HardDelete() func(m featureSettings) { 10 return func(m featureSettings) { 11 m.SetSoftDelete(false) 12 } 13 } 14 15 func WhereStmtNotEmpty() func(m featureSettings) { 16 return func(m featureSettings) { 17 m.SetWhereStmtNotEmpty(true) 18 } 19 } 20 21 type OptionFunc func(m featureSettings) 22 23 type featureSettings interface { 24 SetSoftDelete(flag bool) 25 SetWhereStmtNotEmpty(flag bool) 26 } 27 28 type feature struct { 29 softDelete bool 30 whereStmtNotEmpty bool 31 } 32 33 func (f *feature) SetSoftDelete(softDelete bool) { 34 f.softDelete = softDelete 35 } 36 37 func (f *feature) SetWhereStmtNotEmpty(whereStmtNotEmpty bool) { 38 f.whereStmtNotEmpty = whereStmtNotEmpty 39 }