light modification
This commit is contained in:
@@ -69,10 +69,13 @@ func (dca *resourceMongoAccessor[T]) LoadOne(id string) (utils.DBObject, int, er
|
||||
func (wfa *resourceMongoAccessor[T]) LoadAll(isDraft bool) ([]utils.ShallowDBObject, int, error) {
|
||||
resources, _, err := wfa.ResourceModelAccessor.Search(nil, wfa.GetType().String(), isDraft)
|
||||
return utils.GenericLoadAll[T](func(d utils.DBObject) utils.ShallowDBObject {
|
||||
d.(T).SetAllowedInstances(wfa.Request)
|
||||
if d.(T).GetType() != wfa.GetType().String() {
|
||||
return nil
|
||||
}
|
||||
if err == nil && len(resources) > 0 {
|
||||
d.(T).SetResourceModel(resources[0].(*resource_model.ResourceModel))
|
||||
}
|
||||
d.(T).SetAllowedInstances(wfa.Request)
|
||||
return d
|
||||
}, isDraft, wfa)
|
||||
}
|
||||
@@ -81,10 +84,13 @@ func (wfa *resourceMongoAccessor[T]) Search(filters *dbs.Filters, search string,
|
||||
resources, _, err := wfa.ResourceModelAccessor.Search(nil, wfa.GetType().String(), false)
|
||||
return utils.GenericSearch[T](filters, search, wfa.getResourceFilter(search),
|
||||
func(d utils.DBObject) utils.ShallowDBObject {
|
||||
d.(T).SetAllowedInstances(wfa.Request)
|
||||
if d.(T).GetType() != wfa.GetType().String() {
|
||||
return nil
|
||||
}
|
||||
if err == nil && len(resources) > 0 {
|
||||
d.(T).SetResourceModel(resources[0].(*resource_model.ResourceModel))
|
||||
}
|
||||
d.(T).SetAllowedInstances(wfa.Request)
|
||||
return d
|
||||
}, isDraft, wfa)
|
||||
}
|
||||
@@ -96,7 +102,6 @@ func (abs *resourceMongoAccessor[T]) getResourceFilter(search string) *dbs.Filte
|
||||
return &dbs.Filters{
|
||||
Or: map[string][]dbs.Filter{ // filter by like name, short_description, description, owner, url if no filters are provided
|
||||
"abstractintanciatedresource.abstractresource.abstractobject.name": {{Operator: dbs.LIKE.String(), Value: search}},
|
||||
"abstractintanciatedresource.abstractresource.abstractobject.type": {{Operator: dbs.LIKE.String(), Value: search}},
|
||||
"abstractintanciatedresource.abstractresource.short_description": {{Operator: dbs.LIKE.String(), Value: search}},
|
||||
"abstractintanciatedresource.abstractresource.description": {{Operator: dbs.LIKE.String(), Value: search}},
|
||||
"abstractintanciatedresource.abstractresource.owners.name": {{Operator: dbs.LIKE.String(), Value: search}},
|
||||
|
||||
Reference in New Issue
Block a user