From 9c5f060a2af6c48cb7a73f6fb51dc8868a95012b Mon Sep 17 00:00:00 2001 From: orgin Date: Thu, 3 Mar 2022 15:46:02 +0800 Subject: [PATCH] =?UTF-8?q?mongodb=E7=B4=A2=E5=BC=95=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E5=88=9B=E5=BB=BA=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sysmodule/mongomodule/mongomodule.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sysmodule/mongomodule/mongomodule.go b/sysmodule/mongomodule/mongomodule.go index ba1864c..673702b 100644 --- a/sysmodule/mongomodule/mongomodule.go +++ b/sysmodule/mongomodule/mongomodule.go @@ -161,19 +161,21 @@ func (s *Session) NextSeq(db string, collection string, id string) (int, error) } // goroutine safe -func (s *Session) EnsureIndex(db string, collection string, key []string) error { +func (s *Session) EnsureIndex(db string, collection string, key []string, bBackground bool) error { return s.DB(db).C(collection).EnsureIndex(mgo.Index{ Key: key, Unique: false, Sparse: true, + Background: bBackground, }) } // goroutine safe -func (s *Session) EnsureUniqueIndex(db string, collection string, key []string) error { +func (s *Session) EnsureUniqueIndex(db string, collection string, key []string, bBackground bool) error { return s.DB(db).C(collection).EnsureIndex(mgo.Index{ Key: key, Unique: true, Sparse: true, + Background: bBackground, }) }