You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/test/mongo/cmd/main.go

32 lines
652 B

2 years ago
package main
2 years ago
import (
2 years ago
mongo2 "Open_IM/test/mongo"
2 years ago
"context"
"flag"
"fmt"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
2 years ago
func init() {
2 years ago
clientOptions := options.Client().ApplyURI("mongodb://127.0.0.1:37017/openIM/?maxPoolSize=100")
2 years ago
var err error
mongo2.Client, err = mongo.Connect(context.TODO(), clientOptions)
2 years ago
if err != nil {
panic(err)
}
2 years ago
err = mongo2.Client.Ping(context.TODO(), nil)
2 years ago
if err != nil {
panic(err)
}
fmt.Println("Connected to MongoDB!")
}
func main() {
userID := flag.String("userID", "", "userID")
flag.Parse()
2 years ago
fmt.Println("userID:", *userID)
2 years ago
mongo2.GetUserAllChat(*userID)
2 years ago
}