mirror of
https://github.com/safing/portbase
synced 2025-04-20 01:19:08 +00:00
35 lines
634 B
Go
35 lines
634 B
Go
package query
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/safing/portbase/database/accessor"
|
|
)
|
|
|
|
type existsCondition struct {
|
|
key string
|
|
operator uint8
|
|
}
|
|
|
|
func newExistsCondition(key string, operator uint8) *existsCondition {
|
|
return &existsCondition{
|
|
key: key,
|
|
operator: operator,
|
|
}
|
|
}
|
|
|
|
func (c *existsCondition) complies(acc accessor.Accessor) bool {
|
|
return acc.Exists(c.key)
|
|
}
|
|
|
|
func (c *existsCondition) check() error {
|
|
if c.operator == errorPresent {
|
|
return errors.New(c.key)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (c *existsCondition) string() string {
|
|
return fmt.Sprintf("%s %s", escapeString(c.key), getOpName(c.operator))
|
|
}
|