oc-lib/mongo/mongo_utils.go

46 lines
1.3 KiB
Go
Raw Normal View History

2024-07-17 17:19:42 +02:00
package mongo
import (
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
)
// Will store the created collection object for a faster access
var CollectionMap map[string]*mongo.Collection
var IndexesMap map[string][]mongo.IndexModel
func init() {
CollectionMap = make(map[string]*mongo.Collection)
IndexesMap = make(map[string][]mongo.IndexModel)
IndexesMap["data"] = append(IndexesMap["data"], mongo.IndexModel{Keys: bson.D{
{Key: "description", Value:"text"},
{Key: "example", Value:"text"}},
})
IndexesMap["datacenter"] = append(IndexesMap["datacenter"], mongo.IndexModel{Keys: bson.D{
{Key: "description", Value:"text"},
{Key: "example", Value:"text"},
{Key: "owner", Value:"text"}},
})
IndexesMap["storage"] = append(IndexesMap["storage"], mongo.IndexModel{Keys: bson.D{
{Key: "description", Value:"text"},
{Key: "example", Value:"text"}},
})
IndexesMap["processing"] = append(IndexesMap["processing"], mongo.IndexModel{Keys: bson.D{
{Key: "description", Value:"text"},
{Key: "example", Value:"text"},
{Key: "owner", Value:"text"},
},
})
IndexesMap["workflow"] = append(IndexesMap["workflow"], mongo.IndexModel{Keys: bson.D{
{Key: "description", Value:"text"},
{Key: "example", Value:"text"},
{Key: "owner", Value:"text"},
},
})
}