mongo
This commit is contained in:
		
							
								
								
									
										60
									
								
								mongo.go
									
									
									
									
									
								
							
							
						
						
									
										60
									
								
								mongo.go
									
									
									
									
									
								
							| @@ -16,13 +16,6 @@ var ( | |||||||
| 	mngoClient *mongo.Client | 	mngoClient *mongo.Client | ||||||
| 	mngoDB     *mongo.Database | 	mngoDB     *mongo.Database | ||||||
| 	MngoCtx    context.Context | 	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 | // Trying to get vscode to display this | ||||||
| @@ -51,11 +44,6 @@ func MongoInit() { | |||||||
|  |  | ||||||
| 	DBname = conf["DCNAME"] + "-" + conf["DBPOINT"] | 	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) | 	logger.Info().Msg("Connecting to" + MongoURL) | ||||||
| 	MngoCtx, cancel = context.WithTimeout(context.Background(), 10*time.Second) | 	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) | 	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"} | 	list_collection := [...]string{"Data","Computing","Storage","Datacenter","Workspace","Schedule"} | ||||||
|  |  | ||||||
| 	for _, collection_name := range(list_collection){ | 	for _, collection_name := range(list_collection){ | ||||||
| @@ -119,47 +100,6 @@ func prepareDB(dc_name string, db_point string) { | |||||||
| 		createCollection(new_collection) | 		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)  { | func createCollection(new_collection *mongo.Collection)  { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user