Adjust Mongo

This commit is contained in:
mr
2026-01-26 10:36:15 +01:00
parent 6b12aa1713
commit bc94f2b188
7 changed files with 133 additions and 96 deletions

View File

@@ -289,29 +289,8 @@ func (m *MongoDB) Search(filters *dbs.Filters, collection_name string) (*mongo.C
opts := options.Find()
opts.SetLimit(1000)
targetDBCollection := CollectionMap[collection_name]
orList := bson.A{}
andList := bson.A{}
f := bson.D{}
if filters != nil {
for k, filter := range filters.Or {
for _, ff := range filter {
orList = append(orList, dbs.StringToOperator(ff.Operator).ToMongoOperator(k, ff.Value))
}
}
for k, filter := range filters.And {
for _, ff := range filter {
andList = append(andList, dbs.StringToOperator(ff.Operator).ToMongoOperator(k, ff.Value))
}
}
if len(orList) > 0 && len(andList) == 0 {
f = bson.D{{"$or", orList}}
} else {
if len(orList) > 0 {
andList = append(andList, bson.M{"$or": orList})
}
f = bson.D{{"$and", andList}}
}
}
f := dbs.GetBson(filters)
MngoCtx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
// defer cancel()