2020-09-23 10:41:09 +00:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/services/object/search/query"
|
|
|
|
)
|
|
|
|
|
|
|
|
// FIXME: this is a temporary solution for object fields filters
|
|
|
|
|
2020-10-01 09:02:53 +00:00
|
|
|
const keyParentField = "Object.Header.Split.WithChildren"
|
|
|
|
|
|
|
|
const keyNoChildrenField = "Object.Header.Split.NoChildren"
|
2020-09-23 10:41:09 +00:00
|
|
|
|
|
|
|
const keyParentIDField = "Object.Header.Split.Parent"
|
|
|
|
|
|
|
|
func NewEmptyChildrenFilter() *Filter {
|
2020-10-01 09:02:53 +00:00
|
|
|
return NewFilterEqual(keyNoChildrenField, "")
|
2020-09-23 10:41:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewParentIDFilter(par *object.ID) *Filter {
|
|
|
|
return NewFilterEqual(keyParentIDField, idValue(par))
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewRightChildQuery(par *object.ID) query.Query {
|
|
|
|
return New(
|
|
|
|
NewParentIDFilter(par),
|
|
|
|
NewEmptyChildrenFilter(),
|
|
|
|
)
|
|
|
|
}
|
2020-10-01 09:02:53 +00:00
|
|
|
|
|
|
|
func NewLinkingQuery(par *object.ID) query.Query {
|
|
|
|
return New(
|
|
|
|
NewParentIDFilter(par),
|
|
|
|
NewFilterEqual(keyParentField, ""),
|
|
|
|
)
|
|
|
|
}
|