peeeers
This commit is contained in:
parent
c34e5579fc
commit
1a55212378
@ -1,6 +1,8 @@
|
|||||||
package peer
|
package peer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"cloud.o-forge.io/core/oc-lib/dbs"
|
"cloud.o-forge.io/core/oc-lib/dbs"
|
||||||
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
|
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
@ -67,11 +69,20 @@ func (wfa peerMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) {
|
|||||||
func (wfa *peerMongoAccessor) Search(filters *dbs.Filters, search string) ([]utils.ShallowDBObject, int, error) {
|
func (wfa *peerMongoAccessor) Search(filters *dbs.Filters, search string) ([]utils.ShallowDBObject, int, error) {
|
||||||
objs := []utils.ShallowDBObject{}
|
objs := []utils.ShallowDBObject{}
|
||||||
if (filters == nil || len(filters.And) == 0 || len(filters.Or) == 0) && search != "" {
|
if (filters == nil || len(filters.And) == 0 || len(filters.Or) == 0) && search != "" {
|
||||||
filters = &dbs.Filters{
|
s, err := strconv.Atoi(search)
|
||||||
Or: map[string][]dbs.Filter{ // search by name if no filters are provided
|
if err == nil {
|
||||||
"abstractobject.name": {{Operator: dbs.LIKE.String(), Value: search}},
|
filters = &dbs.Filters{
|
||||||
"url": {{Operator: dbs.LIKE.String(), Value: search}},
|
Or: map[string][]dbs.Filter{ // search by name if no filters are provided
|
||||||
},
|
"state": {{Operator: dbs.LIKE.String(), Value: s}},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
filters = &dbs.Filters{
|
||||||
|
Or: map[string][]dbs.Filter{ // search by name if no filters are provided
|
||||||
|
"abstractobject.name": {{Operator: dbs.LIKE.String(), Value: search}},
|
||||||
|
"url": {{Operator: dbs.LIKE.String(), Value: search}},
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res_mongo, code, err := mongo.MONGOService.Search(filters, wfa.GetType())
|
res_mongo, code, err := mongo.MONGOService.Search(filters, wfa.GetType())
|
||||||
|
Loading…
Reference in New Issue
Block a user