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
2
votes
2 answers

Prevent default creation of MongoDB database programmatically

Is there a way to check for the existence of Mongo Database via Java API without creating the database on initiating the call? I am currently using Casbah (Scala Driver) to interact with our Mongo Instance val mongo = MongoConnection(List(new…
conikeec
  • 209
  • 2
  • 14
2
votes
1 answer

Compilation error on MongoDB Casbah for Scala

I am wrting an update query on Scala and Cashbah. When I write this... val query = MongoDBObject({"_id" -> uri.toString}) val update: DBObject = $set("uDate" -> new DateTime) ++ $addToSet("appearsOn") $each(sourceToAppend:_*) ++ …
Umut Benzer
  • 3,476
  • 4
  • 36
  • 53
2
votes
1 answer

Play2 + Casbah: How to provide an implicit Writes for ObjectId

there is a simple model class that contains some database ids. It looks like this: case class Post(id: ObjectId, owner: Option[ObjectId], title: String) object Post { implicit val implicitPostWrites = Json.writes[Post] } With this code, the…
schub
  • 912
  • 1
  • 8
  • 26
2
votes
2 answers

Scala: Example of using Casbah to write / update / delete objects in MongoDB?

Can not find any description in Casbah tutorial (http://mongodb.github.com/casbah/tutorial.html) how to write / update / delete objects in MongoDB. Please, help with examples or tell what classes to look for these methods. Thanks!
Anton Ashanin
  • 1,817
  • 5
  • 30
  • 43
2
votes
3 answers

Scala and Casbah - error: Option[com.mongodb.DBObject] does not take parameters

I'm trying to fetch doc and get it's attribute. When I use findOne method, I expect to get MongoDBObject, but I receive Option[com.mongodb.DBObject]. How to get an attribute from it? Is it possible to get MongoDBObject instead of this? scala> var…
un1t
  • 4,259
  • 2
  • 30
  • 33
2
votes
1 answer

Is there a more idiomatic way to use Casbah to check a password?

I have the following code: def authenticateByUsername(username: String, password:String): Boolean = { val user = users.findOne(MongoDBObject(USERNAME -> username)) if(user.isDefined){ val pw = user.get.getAs(PASSWORD) …
wfbarksdale
  • 7,498
  • 15
  • 65
  • 88
2
votes
2 answers

NoClassDefFoundError => ClassPath$JavaContext when using play start

I've made a little Scala, Play2.0.2 application. It works fine when i use play run command, but when i use play start or play clean compile stage + target/start, when trying to do a MongoDB insertion with Casbah/Salat, i get the following…
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
2
votes
2 answers

Executing custom function on MongoDB using Casbah/Scala

I've defined a function in MongoDB using its command line client. function something(){...} I was wondering how can I execute a custom MongoDB function using casbah from Scala. Any recommendations ? Thanks,
Ali Salehi
  • 6,899
  • 11
  • 49
  • 75
1
vote
1 answer

Salat Error: class file needed by SalatDAO is missing. reference type MongoCollection of com.mongodb.casbah.TypeImports refers to nonexisting symbol

I'm getting the following error when I try to extend SalatDAO or use grater[T].asObject(x): class file needed by SalatDAO is missing. reference type MongoCollection of com.mongodb.casbah.TypeImports refers to nonexisting symbol. I've followed…
fin
  • 39
  • 5
1
vote
1 answer

Efficiently Update a List of Cursor and insert into collection in Casbah

I am querying a collection and I want to update the results. I want to update a field and let the remaining fields untouched. I have entries with "filename" and "projectId" as keys In this case I am doing: val olderFiles = conn.find(query ++…
JaimeJorge
  • 1,885
  • 16
  • 15
1
vote
2 answers

Close Connection for Mongodb using Casbah API

I am not getting any useful information about "how to close connection for mongodb using casbah API". Actually, I have defined multiple methods and in each method I need to establish a connection with mongodb. After working I need to close that too.…
skg
  • 347
  • 1
  • 3
  • 7
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

Removing documents while preserving at least one

I have a MongoDB collection containing history data with id and timestamp. I want to delete data from the collection older than a specific timestamp. But for every id at least one document (the newest) must stay in the collection. Suppose I have…
Christian
  • 4,543
  • 1
  • 22
  • 31
1
vote
0 answers

Find min/max values for two intervals using mongo aggregation

I have a use-case where I need to fetch max value from one interval and min value from another interval. This has to happen for all unique domains in collection. This collection contains domain and when it was visited. Domain can be visited several…
Shailesh
  • 358
  • 2
  • 13
1
vote
1 answer

What scala domain models for play framework 1.2.2RC1+ looks like when using Casbah?

The documentation for Casbah does not mention play framework. What is the format of scala domain model for Casbah in Play framework 1.2.2RC1+ and how do I make queries ?
ace
  • 11,526
  • 39
  • 113
  • 193