mirror of
https://github.com/safing/portbase
synced 2025-09-14 17:19:51 +00:00
Add query package with first set of conditions and tests
This commit is contained in:
parent
1bf7e42d8a
commit
6ed50f34fb
16 changed files with 933 additions and 0 deletions
31
database/query/condition-and.go
Normal file
31
database/query/condition-and.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package query
|
||||
|
||||
// And combines multiple conditions with a logical _AND_ operator.
|
||||
func And(conditions ...Condition) Condition {
|
||||
return &andCond{
|
||||
conditions: conditions,
|
||||
}
|
||||
}
|
||||
|
||||
type andCond struct {
|
||||
conditions []Condition
|
||||
}
|
||||
|
||||
func (c *andCond) complies(f Fetcher) bool {
|
||||
for _, cond := range c.conditions {
|
||||
if !cond.complies(f) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *andCond) check() (err error) {
|
||||
for _, cond := range c.conditions {
|
||||
err = cond.check()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue