logs on search

This commit is contained in:
mr 2024-07-30 08:39:28 +02:00
parent 50cecc40c4
commit 0e96b5c01a

View File

@ -207,7 +207,7 @@ func (m *MongoDB) StoreOne(obj interface{}, id string, collection_name string) (
bson.Unmarshal(b, &doc)
doc["_id"] = id
targetDBCollection := CollectionMap[collection_name]
fmt.Println("DB", targetDBCollection)
fmt.Println("DB", collection_name, targetDBCollection, CollectionMap)
MngoCtx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
@ -253,10 +253,7 @@ func (m *MongoDB) Search(search string, filter []string, collection_name string)
if cursor, err := targetDBCollection.Find(
MngoCtx,
bson.M{"$or": []bson.M{
{"name": bson.M{"$regex": search, "$options": "i"}},
{"description": bson.M{"$regex": search, "$options": "i"}},
}},
bson.M{"name": bson.M{"$regex": search, "$options": "i"}},
opts,
); err != nil {
fmt.Println(0, bson.M{"$or": list})