missing context on search
This commit is contained in:
parent
d77a403150
commit
2f6fab2f7b
@ -242,7 +242,7 @@ func (m *MongoDB) Search(search string, filter []string, collection_name string)
|
||||
if strings.TrimSpace(search) == "*" {
|
||||
search = ""
|
||||
} else {
|
||||
search = `(?i).*` + search + `.*`
|
||||
search = `(?i).*` + strings.TrimSpace(search) + `.*`
|
||||
}
|
||||
targetDBCollection := CollectionMap[collection_name]
|
||||
list := []bson.M{}
|
||||
@ -253,7 +253,11 @@ func (m *MongoDB) Search(search string, filter []string, collection_name string)
|
||||
defer cancel()
|
||||
|
||||
if cursor, err := targetDBCollection.Find(
|
||||
MngoCtx, bson.M{"$or": list},
|
||||
MngoCtx,
|
||||
bson.M{"$or": []bson.M{
|
||||
{"name": bson.M{"$regex": search}},
|
||||
{"description": bson.M{"$regex": search}},
|
||||
}},
|
||||
opts,
|
||||
); err != nil {
|
||||
fmt.Println(0, bson.M{"$or": list})
|
||||
|
Loading…
Reference in New Issue
Block a user