Questions tagged [mongodb-scala]

MongoDB is a scalable, high-performance, open source, document-oriented database. This tag is used for questions related to the Scala driver for MongoDB.

The Scala Driver Documentation.

40 questions
2
votes
2 answers

Given a particular record, retrieving the previous one in a MongoDB collection

I am fairly new to working with MongoDB. I need to retrieve the previous record of a given record in a MongoDB collection. Is it possible to do this with "_id = ObjectId(...)" field? If not, will we have to explicitly insert a key with a…
hel
  • 453
  • 4
  • 12
2
votes
1 answer

Ensuring indexes with MongoDB using Salat DAOs

There is a post on composite keys using Salat, but information on ensuring indexes (from mongo-db console, db.collection.ensureIndex({someField : 1})) is lacking. Looking through Salat source, I didn't see an annotation for marking a field as…
DK_
  • 2,648
  • 2
  • 21
  • 20
2
votes
1 answer

How to override a gridfs file within the Play Framework using reactivemongo?

I have the following code to write a gridfs file: request.body.files.toList.lastOption match { case Some(picture) => { val filename = picture.filename val contentType = picture.contentType picture.ref.moveTo(new File("/tmp/"…
1
vote
1 answer

Scala MongoDB Casbah need to build a dynamic $or query

Using Scala, MongoDB, Casbah. Given a random list of strings: val names = { val listBuffer = new ListBuffer[String] for(n <- 1 to (new Random().nextInt(5) + 1)){ val name = ((new Random().nextInt(26) +…
user1170533
  • 79
  • 1
  • 5
1
vote
1 answer

Fragment Evaluation Error

Can someone tell me what "Fragment evaluation error" means, or where I might look for solutions? I sometimes (but not always) get lots of these errors (without changing my code): [error] ! Fragment evaluation error [error] ThrowableException:…
brandon
  • 675
  • 6
  • 10
1
vote
0 answers

How to ignore Filters.in if no match values in an array

I have the following aggregation pipeline: val sources = Seq("1.1.1.1", "6.6.6.6") val fileTypes = Seq("docx") val files = DB.fileRead.aggregate(Seq( Aggregates.filter(Filters.and( Filters.in("source", sources: _*), …
qiuyang
  • 11
  • 3
1
vote
1 answer

mongo save save more than 1 records at ones

I want to save more than 1 records at one time that means save block of records. Is it possible in mongoDB. if yes plz some one tell. Thanks
Swapnil Sonawane
  • 1,445
  • 3
  • 22
  • 37
1
vote
1 answer

What are the exact steps needed to setup MongoDB with a blank Scala Lift sbt template?

I'm new to web development but have plenty of Scala experience and am trying to get started with Lift. One of the first steps seems to be setting up a database connection so a site can store user information but I can't quite figure out how to do…
toddaaro
  • 33
  • 3
1
vote
1 answer

Casbah's problem with large number of returned objects

Casbah (or the java driver for mongodb) seems to have problem dealing with a large number of returned objects. For example, the following code segment would produce an IllegalArgumentException and won't return a single result (full stack trace…
defoo
  • 5,159
  • 11
  • 34
  • 39
1
vote
1 answer

Mongodb Scala Driver: How to test an error?

I am writing a sort of integration testing using Scala driver for Mongodb (1.1.1). I have a simple insert query and I am able to manage it using either a future or observer in this way: // with…
Randomize
  • 8,651
  • 18
  • 78
  • 133
1
vote
1 answer

How do I get a Date to store as a Date in MongoDB instead of an Int64?

I'm using the new MongoDB Scala Driver. When I store a java.util.Date, it is being stored in MongoDB as an Int64 instead of a MongoDB Date. I have some code that looks like this: implicit val writer = new Writes[Forecast] { def writes(x:…
gknauth
  • 2,310
  • 2
  • 29
  • 44
1
vote
1 answer

In Lift with MongoDB, storing lists of heterogeneous data

I need to make a web service that can will contain lists of objects. One list can contain objects of many types. Here, for example, I have a library of media items. Each item can be either a link or a video, each with their own metadata. I want to…
eje211
  • 2,385
  • 3
  • 28
  • 44
1
vote
1 answer

Multiple documents update mongodb casbah scala

I have two MongoDB collections promo collection: { "_id" : ObjectId("5115bedc195dcf55d8740f1e"), "curr" : "USD", "desc" : "durable bags.", "endDt" : "2012-08-29T16:04:34-04:00", origPrice" : 1050.99, "qtTotal" : 50, …
user2066049
  • 1,371
  • 1
  • 12
  • 26
0
votes
1 answer

How to manage multiple levels of Objects using Casbah and Subset?

I have three objects case class Metric(val name: String, val tags: Map[String, String]) case class Threshold(val metric: Metric, val critical: Long, val warning: Long) class Profile(val name: String, val thresholds: List[Threshold]) I plan to…
sheki
  • 8,991
  • 13
  • 50
  • 69
0
votes
2 answers

MongoDB: Nested query with arrays, and it's performance

I have 2 collections on 2 separate DBs. Both store an array field. I plan to query both at once so that: All collection 1 documents that have elements [A,B] in their array field and their _ids are present in collection 2's array field with a …
parsa
  • 2,628
  • 3
  • 34
  • 44