Questions tagged [reactivemongo]
Asynchronous & Non-Blocking Scala Driver for MongoDB
509
questions
1
vote
0
answers
13
views
Why ReactiveMongoTemplate save does not work with Testcontainers
I have a spring-boot application.
I have entity:
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Document(COLLECTION_NAME)
public class PersonEntity {
public static final String ...
1
vote
0
answers
7
views
Implementing custom commands for ReactiveMongo 1.x.x
In the commands.scala file here of the ReactiveMongo Github repo, we are seeing the following :
trait Command {
private[reactivemongo] def commandKind: CommandKind
}
This is a clear difference from ...
0
votes
1
answer
34
views
How to write JSON reads/writes and also ReactiveMongo handlers when case classes contain a generic type parameter?
In playframework I am trying to write the reads/writes for JSON, along with reactivemongo's BSON handlers for my case class:
import play.api.libs.json._
import reactivemongo.api.bson._
case class ...
0
votes
0
answers
28
views
How to perform partial document updates
Say I have a case class that has other embedded case classes
case class Car(id: String, name: String, manufacturer: Manufacturer, pricing: Pricing, inventory: Inventory)
case class Manufacturer(...)
...
0
votes
0
answers
38
views
My case class contains a property of type Any, how do I create an implicit for Any?
I have a case class like:
case class House(id: Int, name: String, meta: Any)
I get this compile error:
implicit not found for 'House.value': reactivemongo.api.bson.BSONReader[Any]
I tried creating a ...
0
votes
0
answers
13
views
Getting DatabaseException not master with code 10107
I have bunch of tasks that run simultaneously writing to the db (using reactiveMongo), and I get this exception quite allot lately
DatabaseException['not master' (code = 10107)]
and im trying to ...
0
votes
1
answer
26
views
Using array filters when updating a document with ReactiveMongo
Is there a way to use MongoDB's identifier update array filter in ReactiveMongoDB (19.2)? Imagine a db collection schema of:
{
"_id": ObjectId("617942b33b850d6bbc490420"),
&...
0
votes
2
answers
169
views
Connect a mongo atlas connection to play framework app
I can successfully connect a standalone cluster to my Play Framework (2.7) app (with ReactiveMongo 0.17.1) and I can connect Mongo Compass to my replica set (created in MongoDb Atlas) but am having ...
0
votes
0
answers
27
views
How to work with update.one() when UpdateWriteResult seems to be deprecated
I am working on a ReactiveMongo upgrade(0.20.X to 1.0.7) and have noticed that when calling update.one() I get a complex return value of Future[(GenericCollection[collection.Pack] with ...
0
votes
0
answers
46
views
ReactiveMongo query to count documents
I have a problematic mongo query. Problematic because it takes 10-12seconds and that's is why I am looking for a different implementation.
The query is trying to perform a count of how many items are ...
0
votes
1
answer
36
views
Why in runtime the app have java.lang.NoClassDefFoundError: reactivemongo/api/bson/SafeBSONWriter
I have a simple service as an example:
object SimpleService {
def findById(id: String, col: MongoCollections): Future[Option[Simple]] =
collection(col).flatMap(c => c.find(selectorId(id))....
0
votes
0
answers
40
views
How do I use a field value as part of a local field match for the aggregation pipeline stage $lookup
I'm trying to match documents on a $lookup on a field determined by a piped field (using PlayJSON ReactiveMongo), e.g.
val rstLup = PipelineOperator(
cJso(
"lookup",
Json....
2
votes
1
answer
86
views
Could not find implicit value for parameter write eror, yet I defined the handler using the macro
I have the following:
Account.scala
package modules.accounts
import java.time.Instant
import reactivemongo.api.bson._
case class Account(id: String, name: String)
object Account {
type ID = ...
0
votes
0
answers
34
views
How to return the full Object inserted in mongo using post API using ReactiveMongo
I am studying Scala programming to create RestAPI service for my project, using Play framework and ReactiveMongoDB.
I am trying to insert an object to db, and as a response from insert I want to ...
0
votes
0
answers
54
views
Way of updating document with aggregation pipeline in update operation using reactive-mongo api
How can I do this using reactive-mongo api ?
db.students3.update(
{ },
[
{ $set: { average : { $trunc: [ { $avg: "$tests" }, 0 ] }, lastUpdate: "$$NOW" } },
{ $...
0
votes
0
answers
30
views
Update multiple arrays within same document in mongodb
I have an array of arrays as per below example:
{
items: [
{
outer: "A",
contents : [
{
inner: ".."
},
{
inner: ".."
}
]
},
...
1
vote
0
answers
28
views
Cannot Run Example from ReactiveMongo
I am running reactivemongo 0.18.6 and am having an issue around the bulk Update as shown in the "Update a document" section of the documentation: http://reactivemongo.org/releases/0.1x/...
0
votes
0
answers
27
views
ReactiveMongo 0.20.12-Play28 crashing on Startup with a MatchError: Success exception
ReactiveMongo Version (0.20.12-play28)MongoDB version (4.4.3)Operating System (Ubuntu 18.04.5 LTS)JDK ( OpenJDK 1.8.x)Library Dependencies
Play v2.8.7
Expected Behavior
On starting Play Server, ...
0
votes
0
answers
43
views
When calling findAndRemove, what are the happy and error return types?
I want to understand what calling .findAndRemove(document("userId" -> userId)) will return when:
document exists
document doesn't exist
Code:
userColl.findAndRemove(document("...
0
votes
1
answer
170
views
How to store date/time with ReactiveMongo + Play Json into mongodb
I'm trying to store java.time.Instant in mongo's native Date format.
Official ReactiveMongo documentation states that date time should be serialized as
JsObject with a $date JsNumber field with the ...
0
votes
1
answer
48
views
Is there support for compression in ReactiveMongo?
I am using ReactiveMongo as the connector for an Akka-Http, Akka-Streams project. I am creating the MongoConnection as shown below, but the data in the database is compressed using Snappy. No matter ...
1
vote
0
answers
197
views
DatabaseException - cannot nest $ under $in (reactivemongo)
I need to prepare filters on service A side, and then to use them within service B to query it's DB using those filters.
I'm preparing BSONDocument with filters converting them to JSON (service A):
...
0
votes
0
answers
56
views
BSONSerializer for generic JsArray
I need to make a BSONSerializer for my case class Filter that looks the following way.
case class Filter(name: String,
`type`: LogicType,
value: JsArray,
...
0
votes
1
answer
139
views
using enumeratum enum as BSONDocument value does not compile
when I try to wrap my query in BSONDocument and putting my enumeratum enum as the value it docent compile.
for example, my enum:
sealed trait ProcessingStatus extends EnumEntry with UpperSnakecase
...
0
votes
1
answer
60
views
ReactiveMongo with Play-json responsibility's division
I'm using play-json to serialize my incoming jsons to case classes, for example from sqs source, or from api calls.
its a very simple class JsonSerialization that I import where I need it:
object ...
1
vote
1
answer
163
views
Working with ReactiveMongo (for play framework apps) in 2020
I'v set up and new project of playframework 2.8, and my dilemmas are:
1. which dependency should I use:
"org.reactivemongo" %% "reactivemongo" % "1.0"
OR
"org....
0
votes
0
answers
74
views
When trying to cast big number to double I get int (scala)
Im receiving from outside of my scala service an json that include a certain field with a number, for instance 23945616, and in my model this field is amount: Option[Double], but what actually get ...
1
vote
1
answer
106
views
In ReactiveMongo 0.18.8, how can I perform an update of several documents, with different values, in a single command?
I found this answer whilst digging in SO.
Basically, this is exactly what I need. However, it appears that in my current version of ReactiveMongo, which is 0.18.8, db.command(RawCommand(commandDoc)) ...
0
votes
1
answer
145
views
How do I specify multiple Join Conditions with $lookup in ReactiveMongo aggregation framework?
How do I specify multiple Join Conditions with $lookup in ReactiveMongo (0.17.1) with the following in mind? - as per the mongoDB documentation.
users collection
[
{
"name": "...
0
votes
0
answers
136
views
How to use ReactiveMongo streaming with aggregation?
I'm using ReactiveMongo. I want to run a set of pipelines (i.e., use the Mongo aggregation framework) on a collection, and stream the results. I want to retrieve them as BSON documents.
I've seen ...
1
vote
1
answer
90
views
Does ReactiveMongo handle extended JSON to BSON conversion fully?
I have been trying to use reactivemongo to insert some documents into a mongodb collection with a few BSON types.
I am using the Play JSON library to parse and manipulate some documents in extended ...
-1
votes
1
answer
59
views
ReactiveMongo GridFS error saving file from disk
I have an application that uses gridFS to store some images for things. Im using the gridFSBodyParser and controllers work. Now I need to seed some data from disk for a test for a particular edge case,...
1
vote
0
answers
49
views
Can I use the $map aggregation framework operator in ReactiveMongo aggregation framework?
I would like to implement the following aggregation pipeline using Scala Reactive Mongo:
aggregate([
{ "$match": {"_id": ObjectId("5f22aca9b99533f2092b590c")}},
{
...
2
votes
0
answers
103
views
BSON to Play JSON support for Long values
I've started using the play-json/play-json-compat libraries with reactivemongo 0.20.11.
So I can use JSON Play reads/writes while importing the 'reactivemongo.play.json._' package and then easily ...
0
votes
1
answer
92
views
Transactions With JSONCollection instead of BSONCollection
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 '...
0
votes
1
answer
252
views
Is there a BSONDocumentWriter and BSONDocumentReader for JsValue?
Im trying to write a case class to BSONCollection, but i cannot find any Reads and Writes to JsValue.
Is there a BSONDocumentWriter and BSONDocumentReader for JsValue?
Oh any suggesting for how to ...
0
votes
0
answers
193
views
Reactive MongoDB Aggregation Framework Lookup stage with pipeline
How to use Reactive MongoDB Aggregation Framework in the case when required pipeline stage isn't available?
I'm interested in lookup stage with pipeline, but in documentation I found only
...
1
vote
0
answers
818
views
Getting WriteConflict when trying to use mongo transactions (v4.0.12)
My transaction is pretty simple, it looks like this:
def updateReportTransac(metadata: Metadata, expensesIds: List[String], pairings: List[Pairing])(implicit ec: ExecutionContext): Future[Report] = ...
2
votes
1
answer
145
views
Should I create recursive method for retry in mongodb transaction to avoid document level lock error?
I am using mongodb transaction. Sometimes it may happen that for concurrent transaction in same document data update the second transaction will create transient transaction error which will abort the ...
0
votes
1
answer
311
views
How can I connect to an Atlas cluster with the SRV connection string format using ReactiveMongo?
I have a play scala app and i have an atlas cluster which i am trying to connect. According to the ReactiveMongo this is possible. I can add my connection string gotten from Atlas to my app via
...
5
votes
1
answer
134
views
High level of what I will need to do to port ReactiveMongo scala to use cats effects?
Is it correct to say that if I wanted to use ReactiveMongo in something like http4s I will have to wrap all the Future calls that ReactiveMongo returns in a Cats IO effect?
At a high level, what are ...
1
vote
0
answers
62
views
Scala ReactiveMongo findAndUpdate placeholder for specific field
I am trying to use findAndUpdate in case of duplicate records when trying to insert to mongoDB, using scala and reactiveMongo.
The first function receives a document and performs a simple insert query,...
1
vote
0
answers
326
views
Fail to run 2 findAndUpdate queries inside a MongoDB 4.0 transaction
I have two queries I want to inside the transaction, each separately works, but when trying them both together I get this weird error:
"errmsg": "Only servers in a sharded cluster can ...
0
votes
1
answer
124
views
How to use fetchNewObject with update.one ReactiveMongo?
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
...
0
votes
2
answers
227
views
ReactiveMongo connect with MongoConnectionOptions
I was connecting to my MongoDB using MongoConnectionOptions in reactivemongo version 0.15.x. Now I updated to 0.20.11.
The apply() function of the MongoConnectionOptions companion object is ...
0
votes
0
answers
746
views
Given transaction number 1 does not match any in-progress transactions. The active transaction number is -1
I am trying to run transaction in mongodb 4.2.6. The problem I am facing is when I try to create bulk insert (insertMany) transaction does not happen, But in the case on non-bulk-insert (insertOne) ...
1
vote
1
answer
59
views
How to load the ReactiveMongo for both linux and osx when defining the dependancies?
I am trying to setup my RractiveMongo dependancy for both linux and osx platforms.
I tried this:
val mongoShadedNativeLinux = "org.reactivemongo" % "reactivemongo-shaded-native&...
0
votes
1
answer
308
views
ReactiveMongo with generics: "ambiguous implicit values"
I'm not really sure where this error is coming from. I'm trying to migrate from an old .find() method where I could pass Pattern: query: BSONDocument to find and call .one[T] on it. This worked ...
1
vote
0
answers
23
views
Transforming ReactiveMongo JSON with Play JSON
ReactiveMongo's JSON functionality generates objects (JsObject in play-json parlance) rather than scalars for certain MongoDB datatypes like BSONObjectID and BSONDateTime. For example, you get JSON ...
0
votes
1
answer
34
views
Representing a product to store in mongo using ReactiveMongo library
I am trying to model a product for my mongodb collection "products".
So it looks like this:
{
"_id": "abc123",
"sku": "sku123",
"name": "some product name",
"description": "this is a ...