Skip to content

Commit

Permalink
BaseFilter.C() shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
sdfsdhgjkbmnmxc committed Jul 5, 2021
1 parent d14add1 commit 098b6a2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v0.10.1
* BaseFilter.C() shortcut

v0.10.0
* lorm.DoListTx / lorm.DoSetListTx shortcuts
* lorm.List interface
Expand Down
21 changes: 21 additions & 0 deletions filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,24 @@ func (f *BaseFilter) SetLimit(v int) { f.limit = v }
func (f *BaseFilter) SetOffset(v int) { f.offset = v }
func (f *BaseFilter) SetEmpty() { f.empty = true }
func (f *BaseFilter) SetLock(tx *Tx, lock op.Lock) { f.SetTx(tx); f.lock = lock }

// shortcuts

// C = condition
func (f *BaseFilter) C(v op.Expr) { f.Conds.Add(v) }

// EC = empty condition
func (f *BaseFilter) EC(empty bool, v op.Expr) {
if empty {
f.SetEmpty()
} else {
f.Conds.Add(v)
}
}

// MC = maybe condition
func (f *BaseFilter) MC(apply bool, v op.Expr) {
if apply {
f.Conds.Add(v)
}
}

0 comments on commit 098b6a2

Please sign in to comment.