From d77a403150d842f47f813daa260200f2f19fc1a7 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 29 Jul 2024 15:22:14 +0200 Subject: [PATCH] missing context on search --- dbs/mongo/mongo.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dbs/mongo/mongo.go b/dbs/mongo/mongo.go index d8ca398..709ef93 100644 --- a/dbs/mongo/mongo.go +++ b/dbs/mongo/mongo.go @@ -249,6 +249,9 @@ func (m *MongoDB) Search(search string, filter []string, collection_name string) for _, k := range filter { list = append(list, bson.M{k: bson.M{"$regex": search}}) } + MngoCtx, cancel = context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + if cursor, err := targetDBCollection.Find( MngoCtx, bson.M{"$or": list}, opts,