play-reactivemongo

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

ReactiveMongo Extensions: Bulk update using reactive mongo extensions

余生颓废 提交于 2020-01-06 19:30:06
问题 Is there any way to update bulk records. I am trying to update user object using following code: .update($doc("_id" $in (usersIds: _*)), users, GetLastError(), false , true) In above code i am passing, users List. in user list i also add new properties and chage existing properties state, but with this statement the records are not update If i am using following code: .update($doc("_id" $in (usersIds: _*)), $set("inviteStatus" $eq "Invited"), GetLastError(), false , true) The record updated

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...

How to convert JSON String to a BSONDocument

纵饮孤独 提交于 2019-12-19 04:51:08
问题 I have the following function that uses the reactivemongo driver and actually does a good job writing to the database. def writeDocument() = { val document = BSONDocument( "firstName" -> "Stephane", "lastName" -> "Godbillon", "age" -> 29) val future = collection.insert(document) future.onComplete { case Failure(e) => throw e case Success(result) => { println("successfully inserted document with result = " + result) } } } But the limitation of that function is that the JSON is hardcoded into a

How to convert JSON String to a BSONDocument

你说的曾经没有我的故事 提交于 2019-12-19 04:51:07
问题 I have the following function that uses the reactivemongo driver and actually does a good job writing to the database. def writeDocument() = { val document = BSONDocument( "firstName" -> "Stephane", "lastName" -> "Godbillon", "age" -> 29) val future = collection.insert(document) future.onComplete { case Failure(e) => throw e case Success(result) => { println("successfully inserted document with result = " + result) } } } But the limitation of that function is that the JSON is hardcoded into a

Cannot access authenticated MongoDB collection from ReactiveMongo Play app

时光怂恿深爱的人放手 提交于 2019-12-13 15:20:17
问题 I have a MongoDB server where I have enabled authentication and created users with DB-specific permissions. The user for this app is defined as shown below i.e. geoAdmin has read, readWrite and dbOwner permissions for the relevant database: MongoDB shell version: 3.0.0 connecting to: 192.168.2.89/test > use geo_db switched to db geo_db > db.getUser("geoAdmin") { "_id" : "geo_db.geoAdmin", "user" : "geoAdmin", "db" : "geo_db", "roles" : [ { "role" : "read", "db" : "geo_db" }, { "role" :

Get an error message while tring to rewrite ReactiveMongo + BSON to JSON in Play Framework

戏子无情 提交于 2019-12-12 02:53:53
问题 I tried to use Json library to replace Bson library. This is the original code which works. case class City(name: String, population: Int) object City { implicit val reader = Macros.reader[City] } @Singleton class CityController @Inject()(val reactiveMongoApi: ReactiveMongoApi)(implicit exec: ExecutionContext) extends Controller with MongoController with ReactiveMongoComponents { def findByMinPopulation(minPop: Int) = Action.async { import citiesBSON.BatchCommands.AggregationFramework.Match

Idiomatic way of getting a collection in ReactiveMongo

会有一股神秘感。 提交于 2019-12-07 07:27:26
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... what's to proper way of getting a collection? (or, am I missing something completely and Future[Future

Strange MongoError (with ReactiveMongo) when Play reloads application

折月煮酒 提交于 2019-12-07 06:04:42
问题 Very often, when Play reloads the application after a code change, I receive the following error: MongoError['The node set can not be reached! Please check your network connectivity.'] The MongoDB log looks like this: 2016-09-06T18:51:22.609+0200 I NETWORK [initandlisten] waiting for connections on port 27017 2016-09-06T18:53:49.916+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60559 #1 (1 connection now open) 2016-09-06T18:53:51.185+0200 I NETWORK [initandlisten]

Strange MongoError (with ReactiveMongo) when Play reloads application

扶醉桌前 提交于 2019-12-05 09:17:16
Very often, when Play reloads the application after a code change, I receive the following error: MongoError['The node set can not be reached! Please check your network connectivity.'] The MongoDB log looks like this: 2016-09-06T18:51:22.609+0200 I NETWORK [initandlisten] waiting for connections on port 27017 2016-09-06T18:53:49.916+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60559 #1 (1 connection now open) 2016-09-06T18:53:51.185+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:60561 #2 (2 connections now open) 2016-09-06T18:53:51.196+0200 I NETWORK