diff --git a/models/peer/peer_mongo_accessor.go b/models/peer/peer_mongo_accessor.go index d90bcb6..3fe1c39 100644 --- a/models/peer/peer_mongo_accessor.go +++ b/models/peer/peer_mongo_accessor.go @@ -80,6 +80,9 @@ func (a *peerMongoAccessor) getDefaultFilter(search string) *dbs.Filters { }, } } else { + if search == "*" { + search = "" + } return &dbs.Filters{ Or: map[string][]dbs.Filter{ // search by name if no filters are provided "abstractobject.name": {{Operator: dbs.LIKE.String(), Value: search}}, diff --git a/models/resources/resource_accessor.go b/models/resources/resource_accessor.go index 79c8e18..a1760c5 100644 --- a/models/resources/resource_accessor.go +++ b/models/resources/resource_accessor.go @@ -90,6 +90,9 @@ func (wfa *resourceMongoAccessor[T]) Search(filters *dbs.Filters, search string, } func (abs *resourceMongoAccessor[T]) getResourceFilter(search string) *dbs.Filters { + if search == "*" { + search = "" + } 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}}, diff --git a/models/resources/resource_model/resource_model_mongo_accessor.go b/models/resources/resource_model/resource_model_mongo_accessor.go index f0186de..d1b8bdd 100644 --- a/models/resources/resource_model/resource_model_mongo_accessor.go +++ b/models/resources/resource_model/resource_model_mongo_accessor.go @@ -53,6 +53,7 @@ func (a *ResourceModelMongoAccessor) LoadAll(isDraft bool) ([]utils.ShallowDBObj } func (a *ResourceModelMongoAccessor) Search(filters *dbs.Filters, search string, isDraft bool) ([]utils.ShallowDBObject, int, error) { + return utils.GenericSearch[*ResourceModel](filters, search, &dbs.Filters{ Or: map[string][]dbs.Filter{ diff --git a/models/utils/abstracts.go b/models/utils/abstracts.go index 5f1c50f..8617f30 100644 --- a/models/utils/abstracts.go +++ b/models/utils/abstracts.go @@ -88,6 +88,9 @@ func (ao *AbstractObject) VerifyAuth(request *tools.APIRequest) bool { } func (ao *AbstractObject) GetObjectFilters(search string) *dbs.Filters { + if search == "*" { + search = "" + } return &dbs.Filters{ Or: map[string][]dbs.Filter{ // filter by name if no filters are provided "abstractobject.name": {{Operator: dbs.LIKE.String(), Value: search}},