mirror of
https://github.com/PretendoNetwork/wiiu-chat-secure.git
synced 2026-04-24 15:26:57 -05:00
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package database
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"time"
|
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
"go.mongodb.org/mongo-driver/mongo/options"
|
|
)
|
|
|
|
var mongoClient *mongo.Client
|
|
var mongoContext context.Context
|
|
var accountDatabase *mongo.Database
|
|
var doorsDatabase *mongo.Database
|
|
var pnidCollection *mongo.Collection
|
|
var nexAccountsCollection *mongo.Collection
|
|
var regionsCollection *mongo.Collection
|
|
var usersCollection *mongo.Collection
|
|
var sessionsCollection *mongo.Collection
|
|
var callsCollection *mongo.Collection
|
|
var tourneysCollection *mongo.Collection
|
|
|
|
func connectMongo() {
|
|
mongoClient, _ = mongo.NewClient(options.Client().ApplyURI(os.Getenv("PN_WIIU_CHAT_MONGO_URI")))
|
|
mongoContext, _ = context.WithTimeout(context.Background(), 10*time.Second)
|
|
_ = mongoClient.Connect(mongoContext)
|
|
|
|
accountDatabase = mongoClient.Database("pretendo")
|
|
pnidCollection = accountDatabase.Collection("pnids")
|
|
nexAccountsCollection = accountDatabase.Collection("nexaccounts")
|
|
|
|
doorsDatabase = mongoClient.Database("doors")
|
|
usersCollection = doorsDatabase.Collection("users")
|
|
sessionsCollection = doorsDatabase.Collection("sessions")
|
|
callsCollection = doorsDatabase.Collection("calls")
|
|
|
|
sessionsCollection.DeleteMany(context.TODO(), bson.D{})
|
|
callsCollection.DeleteMany(context.TODO(), bson.D{})
|
|
}
|