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