Roc преди 2 месеца
родител
ревизия
c1660f436f
променени са 1 файла, в които са добавени 4 реда и са изтрити 1 реда
  1. 4 1
      utils/mgodb/mgo_config.go

+ 4 - 1
utils/mgodb/mgo_config.go

@@ -8,6 +8,7 @@ import (
 	"go.mongodb.org/mongo-driver/bson"
 	"go.mongodb.org/mongo-driver/event"
 	mgoptions "go.mongodb.org/mongo-driver/mongo/options"
+	"go.mongodb.org/mongo-driver/mongo/writeconcern"
 	"sync"
 )
 
@@ -78,7 +79,9 @@ func MgoNewClient(mgoConfig MgoConfig) *qmgo.Client {
 	}
 
 	// 创建options
-	ops := options.ClientOptions{ClientOptions: &mgoptions.ClientOptions{}}
+	ops := options.ClientOptions{ClientOptions: &mgoptions.ClientOptions{
+		WriteConcern: &writeconcern.WriteConcern{W: "majority"},
+	}}
 	ops.SetMonitor(cmdMonitor)
 
 	ctx := context.Background()