diff --git a/modules/arena/modelarena.go b/modules/arena/modelarena.go index c85c657b4..11c304704 100644 --- a/modules/arena/modelarena.go +++ b/modules/arena/modelarena.go @@ -34,13 +34,15 @@ func (this *modelArena) Init(service core.IService, module core.IModule, comp co this.MCompModel.Init(service, module, comp, opt) this.module = module.(*Arena) //创建uid索引 - _, err = this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ - Keys: bson.A{ - bsonx.Doc{ - {Key: "uid", Value: bsonx.Int32(1)}, - }, - bson.M{"loc": "2dsphere"}, + if _, err = this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{ + {Key: "uid", Value: bsonx.Int32(1)}, }, + }); err != nil { + return + } + _, err = this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bson.M{"loc": "2dsphere"}, }) return }