This commit is contained in:
behrooz razzaghi
2025-03-11 17:31:12 +03:30
commit 3bbe28c5f4
188 changed files with 7821 additions and 0 deletions

24
db/db.go Normal file
View File

@@ -0,0 +1,24 @@
package db
import (
"context"
"log"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
var (
Client *mongo.Client
UserCollection, Vclusters_details *mongo.Collection
)
func InitDB() {
clientOptions := options.Client().ApplyURI("mongodb://root:example@192.168.1.10:27017/")
client, err := mongo.Connect(context.TODO(), clientOptions)
if err != nil {
log.Fatal(err)
}
UserCollection = client.Database("vcluster").Collection("users")
}