light modification
This commit is contained in:
parent
19eb5239a6
commit
e741a95cdb
@ -2,6 +2,7 @@ package resources
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"slices"
|
"slices"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"cloud.o-forge.io/core/oc-lib/dbs"
|
"cloud.o-forge.io/core/oc-lib/dbs"
|
||||||
"cloud.o-forge.io/core/oc-lib/logs"
|
"cloud.o-forge.io/core/oc-lib/logs"
|
||||||
@ -70,9 +71,6 @@ func (wfa *resourceMongoAccessor[T]) LoadAll(isDraft bool) ([]utils.ShallowDBObj
|
|||||||
resources, _, err := wfa.ResourceModelAccessor.Search(nil, wfa.GetType().String(), isDraft)
|
resources, _, err := wfa.ResourceModelAccessor.Search(nil, wfa.GetType().String(), isDraft)
|
||||||
return utils.GenericLoadAll[T](func(d utils.DBObject) utils.ShallowDBObject {
|
return utils.GenericLoadAll[T](func(d utils.DBObject) utils.ShallowDBObject {
|
||||||
d.(T).SetAllowedInstances(wfa.Request)
|
d.(T).SetAllowedInstances(wfa.Request)
|
||||||
if d.(T).GetType() != wfa.GetType().String() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if err == nil && len(resources) > 0 {
|
if err == nil && len(resources) > 0 {
|
||||||
d.(T).SetResourceModel(resources[0].(*resource_model.ResourceModel))
|
d.(T).SetResourceModel(resources[0].(*resource_model.ResourceModel))
|
||||||
}
|
}
|
||||||
@ -85,7 +83,7 @@ func (wfa *resourceMongoAccessor[T]) Search(filters *dbs.Filters, search string,
|
|||||||
return utils.GenericSearch[T](filters, search, wfa.getResourceFilter(search),
|
return utils.GenericSearch[T](filters, search, wfa.getResourceFilter(search),
|
||||||
func(d utils.DBObject) utils.ShallowDBObject {
|
func(d utils.DBObject) utils.ShallowDBObject {
|
||||||
d.(T).SetAllowedInstances(wfa.Request)
|
d.(T).SetAllowedInstances(wfa.Request)
|
||||||
if d.(T).GetType() != wfa.GetType().String() {
|
if strings.Contains(d.(T).GetType(), search) && search != "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err == nil && len(resources) > 0 {
|
if err == nil && len(resources) > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user