[#39] service/object: Add query filters to search right child
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
df5fb23ba8
commit
39c324bd6d
2 changed files with 31 additions and 0 deletions
27
pkg/services/object/search/query/v1/keys.go
Normal file
27
pkg/services/object/search/query/v1/keys.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
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
|
||||
|
||||
const keyChildrenField = "Object.Header.Split.Children"
|
||||
|
||||
const keyParentIDField = "Object.Header.Split.Parent"
|
||||
|
||||
func NewEmptyChildrenFilter() *Filter {
|
||||
return NewFilterEqual(keyChildrenField, "")
|
||||
}
|
||||
|
||||
func NewParentIDFilter(par *object.ID) *Filter {
|
||||
return NewFilterEqual(keyParentIDField, idValue(par))
|
||||
}
|
||||
|
||||
func NewRightChildQuery(par *object.ID) query.Query {
|
||||
return New(
|
||||
NewParentIDFilter(par),
|
||||
NewEmptyChildrenFilter(),
|
||||
)
|
||||
}
|
|
@ -97,6 +97,10 @@ func headerEqual(obj *object.Object, key, value string) bool {
|
|||
return value == cidValue(obj.GetContainerID())
|
||||
case objectSDK.HdrSysNameOwnerID:
|
||||
return value == ownerIDValue(obj.GetOwnerID())
|
||||
case keyChildrenField:
|
||||
return len(obj.GetChildren()) == 0
|
||||
case keyParentIDField:
|
||||
return idValue(obj.GetParent().GetID()) == value
|
||||
// TODO: add other headers
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue