Questions tagged [casbah]

Casbah integrates a Scala toolkit layer on top of the official MongoDB Java driver.

Casbah is end-of-life (EOL):

Users are encouraged to migrate to the Mongo Scala Driver for a modern idiomatic MongoDB Scala driver.

Casbah is a Scala toolkit for MongoDB. We use the term “toolkit” rather than “driver”, as Casbah integrates a layer on top of the official mongo-java-driver for better integration with Scala. This is as opposed to a native implementation of the Mongo Wire Protocol, which the Java driver does exceptionally well. Rather than a complete rewrite, Casbah uses implicits and Pimp My Library code to enhance the existing Java code with fluid, Scala-friendly syntax.

Documentation and source code

Related Links

266 questions
0
votes
1 answer

Avoid to get "system.indexes" as a collection name in casbah

I'm using casbah to find collection names in a mongodb-database val mongoClient = MongoClient() val db = mongoClient("db_name") val coll = db.collectionNames() It also gives 'system.indexes' because each mongo database has that one. Is…
Shashika
  • 1,606
  • 6
  • 28
  • 47
0
votes
2 answers

Some Casbah functions not working

In my project, I'm using Casbah and I reffered http://mongodb.github.io/casbah/tutorial.html tutorial. According to that I've implemented val mongoClient = MongoClient val db = mongoClient("db_name") val coll = db("coll_name") …
Shashika
  • 1,606
  • 6
  • 28
  • 47
0
votes
1 answer

casbah exception on method find and findOne

Can anyone explain me what is happening with this code? There is no database running because the idea is to catch the exception. val col = MongoConnection("localhost")("myDB")("myCol") // Using Try to catch any exception but there is NO…
Aitor ATuin
  • 15
  • 1
  • 3
0
votes
2 answers

Why does $eq behave differently to $ne in casbah?

Why does $eq behave differently to $ne in casbah? import com.mongodb.casbah.Imports._ object O{ val x = "user" $ne "bwmcadams" // Compile fine val y = "user" $eq "bwmcadams" // fails to compile: value = is not a member of string } Built…
user48956
  • 14,850
  • 19
  • 93
  • 154
0
votes
2 answers

The MongoDB Scala binding Casbah query DSL acts strangely with $regex

I have some code attempting to use $regex in a query: val mongoClient = MongoClient() // connect locally val db = mongoClient("testdb") val gridfs = GridFS(db) val x = gridfs.files("filename" $regex "^[a-zA-Z]+\\/.+") x.foreach(println) The idea…
Jeffrey Drake
  • 805
  • 10
  • 26
0
votes
1 answer

Casbah cas from BasicDBObject to my type

I have a collection in the database that looks like below: Question { "_id" : ObjectId("52b3248a43fa7cd2bc4a2d6f"), "id" : 1001, "text" : "Which is a valid java access modifier?", "questype" : "RADIO_BUTTON", …
joesan
  • 13,963
  • 27
  • 95
  • 232
0
votes
3 answers

Casbah Scala Runtime Error

I have a Play framework based webapp which has the following defined in its build.sbt file: .... version := "1.0-SNAPSHOT" resolvers += "Sonatype Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/" resolvers += "Sonatype…
joesan
  • 13,963
  • 27
  • 95
  • 232
0
votes
2 answers

How to Convert MongoDBObject to JsonString

My mongoDb collection looks like this: > db.FakeCollection.find().pretty() { "_id" : ObjectId("52b2d71c5c197846fd3a2737"), "categories" : [ { "categoryname" : "entertainment", "categoryId"…
sagar
  • 143
  • 1
  • 2
  • 11
0
votes
1 answer

How to synchronize Play framework 2 with MongoDB and the steps to be followed

I have been working on this since days now but have not came up with any solution. My target is to create a dummy project which uses Play framework 2 and mongodb as backend with scala used for UI only and the rest would be done in java. Keeping in…
Varun
  • 13
  • 2
0
votes
1 answer

How to Delete a Specific Object From The Arrayof Objects in MongoDB Casbah

mydata is look like below:- { "categories": [ { "categoryname": "Eletronics", "categoryId": "89sxop", "displayname": "Eletronics", "subcategories": [ { "subcategoryname":…
sagar
  • 143
  • 1
  • 2
  • 11
0
votes
2 answers

Salat MongoDB DAO findOneById how to

I have recently started using Scala, Akka and the Salat serialization library for MongoDB. Now I am trying to set up a SalatDAO for objects that look like this: import com.novus.salat.annotations._ case class MyObject(@Key("_id) compId:…
Giovanni Botta
  • 9,626
  • 5
  • 51
  • 94
0
votes
1 answer

With Scala Salat (using mongodb casbah), how to store and load binary data?

I have a product case class defined in the way Salat expects. case class Product(@Key("product_id") productId: String, @Key("png_image_binary") pngImageBinary: ???) How can I add pngImageBinary so I can store this as a binary…
Phil
  • 46,436
  • 33
  • 110
  • 175
0
votes
2 answers

Why is it that I add ORG.mongodb.smth to dependencies and then import COM.mongodb.smth?

I'm doing this from within code in a Scala/SBT project, but I assume this question should equally well apply to Java code. In build.sbt I have: libraryDependencies += "org.mongodb" %% "casbah" % "2.6.3" but then in the code, I need to import for…
Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
0
votes
1 answer

How to delete in MongoDB records whose hour is not a multiple of 12

I am using MongoDB through the Casbah driver and I am storing documents which contain a date field, which is in my java world a Java DateTime. I would need to perform similar queries: Remove all records with day any but hour falling into a certain…
Edmondo
  • 19,559
  • 13
  • 62
  • 115
0
votes
1 answer

Can you catch a 'reconnected' event with Mongo Casbah?

When you have autoConnectRetry=true, is it possible to catch when the connection resumes? I have a backup system, where some non-essential operations are stored in a file if mongo connection fails. I'm processing the operations from this file on…
siltalau
  • 529
  • 3
  • 17