Files
open-im-server/test/mongo/cmd/main.go
T

35 lines
654 B
Go
Raw Normal View History

2022-05-25 17:42:45 +08:00
package main
2022-05-25 17:38:49 +08:00
import (
2022-05-25 17:41:32 +08:00
mongo2 "Open_IM/test/mongo"
2022-05-25 17:38:49 +08:00
"context"
"flag"
"fmt"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
var (
client *mongo.Client
)
2022-05-25 17:41:32 +08:00
func init() {
2022-05-25 17:38:49 +08:00
clientOptions := options.Client().ApplyURI("mongodb://127.0.0.1:37017/openIM/?maxPoolSize=100")
client, err := mongo.Connect(context.TODO(), clientOptions)
if err != nil {
panic(err)
}
err = client.Ping(context.TODO(), nil)
if err != nil {
panic(err)
}
fmt.Println("Connected to MongoDB!")
}
func main() {
userID := flag.String("userID", "", "userID")
flag.Parse()
fmt.Println("userID:", userID)
2022-05-25 17:41:32 +08:00
mongo2.GetUserAllChat(*userID)
2022-05-25 17:38:49 +08:00
}