mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
index fix
This commit is contained in:
parent
7dc1f9b81b
commit
6b30097bde
@ -100,7 +100,7 @@ func init() {
|
||||
}
|
||||
if err := createMongoIndex(mongoClient, cChat, false, "uid"); err != nil {
|
||||
fmt.Println("uid", " index create failed", err.Error())
|
||||
panic(err.Error())
|
||||
//panic(err.Error())
|
||||
}
|
||||
if err := createMongoIndex(mongoClient, cWorkMoment, true, "-create_time", "work_moment_id"); err != nil {
|
||||
fmt.Println("-create_time", "work_moment_id", "index create failed", err.Error())
|
||||
@ -192,19 +192,11 @@ func createMongoIndex(client *mongo.Client, collection string, isUnique bool, ke
|
||||
keysDoc = keysDoc.Append(key, bsonx.Int32(1))
|
||||
}
|
||||
}
|
||||
var index mongo.IndexModel
|
||||
if utils.IsContain("uid", keys) {
|
||||
name := "uid_new"
|
||||
index = mongo.IndexModel{
|
||||
Keys: keysDoc,
|
||||
Options: &options.IndexOptions{Name: &name},
|
||||
}
|
||||
} else {
|
||||
index = mongo.IndexModel{
|
||||
Keys: keysDoc,
|
||||
}
|
||||
}
|
||||
|
||||
// 创建索引
|
||||
index := mongo.IndexModel{
|
||||
Keys: keysDoc,
|
||||
}
|
||||
if isUnique == true {
|
||||
index.Options = options.Index().SetUnique(true)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user