From 5e6e1a24a2f7b3d382a2dd814358c574ff736998 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 29 Dec 2023 15:13:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=A5=BD=E5=8F=8B=E5=94=AF?= =?UTF-8?q?=E4=B8=80=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/friend/model_friend.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/friend/model_friend.go b/modules/friend/model_friend.go index 30dec2f7d..f12b1c7cd 100644 --- a/modules/friend/model_friend.go +++ b/modules/friend/model_friend.go @@ -9,6 +9,7 @@ import ( "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" + mgooptions "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/x/bsonx" ) @@ -22,7 +23,8 @@ func (this *ModelFriend) Init(service core.IService, module core.IModule, comp c err = this.MCompModel.Init(service, module, comp, options) this.moduole = module.(*Friend) this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ - Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + Options: mgooptions.Index().SetUnique(true), }) this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ Keys: bsonx.Doc{{Key: "assistHeroId", Value: bsonx.Int32(1)}},