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

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