mirror of
https://github.com/safing/portbase
synced 2025-09-16 10:09:49 +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
28
database/query/condition-exists.go
Normal file
28
database/query/condition-exists.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package query
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
type existsCondition struct {
|
||||
key string
|
||||
operator uint8
|
||||
}
|
||||
|
||||
func newExistsCondition(key string, operator uint8) *existsCondition {
|
||||
return &existsCondition{
|
||||
key: key,
|
||||
operator: operator,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *existsCondition) complies(f Fetcher) bool {
|
||||
return f.Exists(c.key)
|
||||
}
|
||||
|
||||
func (c *existsCondition) check() error {
|
||||
if c.operator == errorPresent {
|
||||
return errors.New(c.key)
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue