How to set the write concern for insert query with ReactiveMongo
Asked Answered
Y

0

6

How can I write the following query in ReactiveMongo.

db.products.insert(
   { item: "envelopes", qty : 100, type: "Clasp" },
   { writeConcern: { w: 2, wtimeout: 5000 } }
)

I have tried the like below.

db.products.insert(BSONDocument("item"->"envelopes","qty " -> 100,"type" -> "Clasp"))

Can you please suggest here how can I write the insert query with write concern in ReactiveMongo.

I have used writeConcern majority in DB connection like

val conOpts = MongoConnectionOptions(authMode = ScramSha1Authentication, authSource = Some(Configuration.dbName), writeConcern = WriteConcern.Default.copy(w = WriteConcern.Majority))
Ymir answered 16/2, 2018 at 6:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.