This commit is contained in:
pb 2024-07-16 10:56:42 +02:00
parent 034a81cedb
commit f0eec45836

View File

@ -16,13 +16,6 @@ var (
mngoClient *mongo.Client
mngoDB *mongo.Database
MngoCtx context.Context
MngoCollData *mongo.Collection
MngoCollComputing *mongo.Collection
MngoCollStorage *mongo.Collection
MngoCollDatacenter *mongo.Collection
MngoCollWorkspace *mongo.Collection
MngoCollSchedule *mongo.Collection
)
// Trying to get vscode to display this
@ -51,11 +44,6 @@ func MongoInit() {
DBname = conf["DCNAME"] + "-" + conf["DBPOINT"]
// MongoURL, err := beego.AppConfig.String(baseConfig + "::url")
// if err != nil {
// logger.Critical().Msg("MongoDB URI error: %v", err)
// panic(err)
// }
logger.Info().Msg("Connecting to" + MongoURL)
MngoCtx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
@ -105,13 +93,6 @@ func prepareDB(dc_name string, db_point string) {
mngoDB = mngoClient.Database(DBname)
MngoCollData = mngoDB.Collection("Data")
MngoCollComputing = mngoDB.Collection("Computing")
MngoCollStorage = mngoDB.Collection("Storage")
MngoCollDatacenter = mngoDB.Collection("Datacenter")
MngoCollWorkspace = mngoDB.Collection("Workspace")
MngoCollSchedule = mngoDB.Collection("Schedule")
list_collection := [...]string{"Data","Computing","Storage","Datacenter","Workspace","Schedule"}
for _, collection_name := range(list_collection){
@ -119,47 +100,6 @@ func prepareDB(dc_name string, db_point string) {
createCollection(new_collection)
}
// if _, err = MngoCollComputing.Indexes().CreateMany(MngoCtx, []mongo.IndexModel{
// {
// Keys: bsonx.Doc{
// {Key: "description", Value: bsonx.String("text")},
// {Key: "owner", Value: bsonx.String("text")},
// {Key: "license", Value: bsonx.String("text")},
// },
// },
// }); err != nil && err.(mongo.CommandError).Code != 85 {
// logger.Critical().Msg(err)
// panic(err)
// }
// if _, err = MngoCollStorage.Indexes().CreateMany(MngoCtx, []mongo.IndexModel{
// {
// Keys: bsonx.Doc{
// {Key: "name", Value: bsonx.String("text")},
// {Key: "description", Value: bsonx.String("text")},
// },
// },
// }); err != nil && err.(mongo.CommandError).Code != 85 {
// logger.Critical().Msg(err)
// panic(err)
// }
// if _, err = MngoCollDatacenter.Indexes().CreateMany(MngoCtx, []mongo.IndexModel{
// {
// Keys: bsonx.Doc{
// {Key: "name", Value: bsonx.String("text")},
// {Key: "description", Value: bsonx.String("text")},
// {Key: "owner", Value: bsonx.String("text")},
// },
// },
// }); err != nil && err.(mongo.CommandError).Code != 85 {
// logger.Critical().Msg(err)
// panic(err)
// }
}
func createCollection(new_collection *mongo.Collection) {