reactivemongo

How to use fetchNewObject with update.one ReactiveMongo?

不想你离开。 提交于 2021-01-29 05:14:26
问题 Previously I used findAndUpdate and could add fetchNewObject = true so I was able to do something like this after the query: .map(_.result[WhicherReport].getOrElse { throw new NoSuchElementException }) but I'm using transaction now and could only perform update.one(...) and there is no option to pass it fetchNewObject , what can I do? This is my func: def someUpdateFunc(collection: BSONCollection, metadata: Metadata, ids: List[String]): Future[UpdateWriteResult] = { collection.update.one( q =

Transactions With JSONCollection instead of BSONCollection

社会主义新天地 提交于 2020-08-10 18:57:05
问题 I have a problem to make Transaction via JSONCollection, I getting the following error: JsResultException(errors:List((,List(JsonValidationError(List(CommandError[code=14, errmsg=BSON field 'OperationSessionInfo.txnNumber' is the wrong type 'int', expected type 'long', doc: {"operationTime":{"$time":1596894245,"$i":5,"$timestamp":{"t":1596894245,"i":5}},"ok":0,"errmsg":"BSON field 'OperationSessionInfo.txnNumber' is the wrong type 'int', expected type 'long'","code":14,"codeName":

Is there any way to perform bulk updates on ReactiveMongo?

落花浮王杯 提交于 2020-02-06 03:50:27
问题 Suppose I want to do the following (in mongo shell): var bulk = db.vectors.initializeOrderedBulkOp() bulk.find({"_id" : ObjectId("53f265da13d3f885ed8bf75d")}).updateOne({"$pop": {"v": 1}}) bulk.find({"_id" : ObjectId("53f265da13d3f885ed8bf75d")}).updateOne({"$push": {"v": 5}}) bulk.execute() 回答1: I found the answer! ReactiveMongo has RawCommand command that let us run any MongoDB command (like update, in this case >> http://docs.mongodb.org/manual/reference/command/update/#dbcmd.update): val

MongoError No primary node is available

ぐ巨炮叔叔 提交于 2020-01-13 09:44:48
问题 We have upgraded to Play 2.7.0 recently and use play2-reactivemongo version 0.16.2 with reactivemongo 0.16.3. We use reactivemongo-shaded-native but also tried without. We are connecting to a replica set with 3 nodes, MongoDB 3.6.10 on MongoDB Atlas. The initial connection is fine and the service is running OK for a while. But in the end we hit this error: [error] 2019-02-15 09:40:30,466 r.api.Failover2 - [Supervisor-1/Connection-2] Got an error, no more attempts to do. Completing with a

How to use ReactiveMongo with an enum?

ε祈祈猫儿з 提交于 2020-01-05 13:48:30
问题 I am working with the Play Framework and ReactiveMongo. I am trying to write a reader and a writer for my class called Platforms. I am trying to use a type that I created as scala enum, but I don't know how the reader/writer syntax should be defined. Can someone help me figure out the correct syntax? import reactivemongo.bson._ sealed trait PlatformType { def name: String } case object PROPER extends PlatformType { val name = "PROPER" } case object TRANSACT extends PlatformType { val name =

How to use ReactiveMongo with an enum?

安稳与你 提交于 2020-01-05 13:46:44
问题 I am working with the Play Framework and ReactiveMongo. I am trying to write a reader and a writer for my class called Platforms. I am trying to use a type that I created as scala enum, but I don't know how the reader/writer syntax should be defined. Can someone help me figure out the correct syntax? import reactivemongo.bson._ sealed trait PlatformType { def name: String } case object PROPER extends PlatformType { val name = "PROPER" } case object TRANSACT extends PlatformType { val name =

Idiomatic way of getting a collection in ReactiveMongo

戏子无情 提交于 2020-01-03 04:24:17
问题 I'm writing a Play/Scala application using Play 2.5.4 and ReactiveMongo. Based on this example, I'm getting the collection using class SettingStore( val mongo:ReactiveMongoApi) { def collection = mongo.db.collection[BSONCollection]("Settings") // more code... } However, db is now deprecated. The deprecation warning recommends I use database , but this one returns a Future so all operations have to be mapped over. Since ReactiveMongo's operations also return Future s, this seems redundant...