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
1
vote
2 answers

casbah cursor and toList

I have a cursor in casbah, returned from a query. If I iterate over the cursor I get a certain number of results, x. If I execute the same query and do a toList on the cursor, I get list of size y, a different number. Why? I'm calling this from a…
Greg
  • 10,696
  • 22
  • 68
  • 98
1
vote
2 answers

Insert new record using Scala Salat/Casbah and Mongodb

Greetings, I am using Salat and Casbah to create a user collection in Mongodb, everything works great until I added a unique index on the email field. Now my insert returns a unique id with no actual record added in the DB for existing email…
user1521903
  • 151
  • 2
  • 6
1
vote
1 answer

Scala Casbah MongoDB driver - Maven error

What is the correct way to set up Casbah MongoDB driver in Maven? I have the following error when I tried to run Maven build, I get the following error: [ERROR] The following artifacts could not be resolved: org.mongodb:casbah_2.10:jar:2.5.1,…
joesan
  • 13,963
  • 27
  • 95
  • 232
1
vote
3 answers

Scala + Eclipse + Casbah = object mongodb is not a member of package com

I'm using spray with casbah and salat. I get this error when I import the casbah imports, import com.mongodb.casbah.Imports._ object mongodb is not a member of package com However, sbt compiles successfully w/o any warning. My build.sbt…
azyoot
  • 1,162
  • 8
  • 18
1
vote
2 answers

Pagination solution for Salat/Cashbah

I am interested in a pagination solution for documents stored in MongoDB. I use Salat/Casbah in order to work with this data. As far as I can tell, there is nothing readily available in as far as open source to paginate data using those two…
randombits
  • 47,058
  • 76
  • 251
  • 433
1
vote
1 answer

Scala Salat Deserialization: how to get a Map[String, Number]?

My database looks like [ { name: "domenic", records: { today: 5, yesterday: 1.5 } }, { name: "bob", records: { ... } } ] When I try queries like val result: Option[DBObject] = myCollection.findOne( …
Domenic
  • 110,262
  • 41
  • 219
  • 271
1
vote
1 answer

How to pass a Casbah result to view in Play Framework?

Basically what I want to achieve is simply to execute a MongoDB query using Casbah in a Play Framework 2.2 controller, pass the result(s) to a view and present the result(s) in HTML. I think my main problem is, I don't know how to define the…
Nick
  • 2,576
  • 1
  • 23
  • 44
1
vote
1 answer

Add a set of strings to an existing set with casbah

I have a user object as follows: { user: "joe", acks: ["a", "b" ] } I want to add a set of strings to the acks field. Here's my attempt to do this with one update: def addSomeAcks(toBeAcked = Array[String]) …
John in MD
  • 2,141
  • 5
  • 25
  • 36
1
vote
1 answer

Nested query DSL in casbah?

How can I do a nested and/or query in casbah? For example: val q = $and( "a"->"b", $or("e"->"f", "e"->"g"), $or("c"->"d", "c"->"e") ) This sample doesn't compile, but that's the idea I'm trying to achieve.
Greg
  • 10,696
  • 22
  • 68
  • 98
1
vote
1 answer

Infinite TTL for MongoDB collection

Do we have some way to mark index with expireAfterSeconds property as infinite. I want to do this in order not to be forced to drop index later, and just change TTL using collMod. Or maybe we have some maximum value for expireAfterSeconds property?…
Eddie Jamsession
  • 1,006
  • 6
  • 24
1
vote
1 answer

how to Update nested Arrayof objects in mongoDB using Casbah

My MongoDB Data looking like Below:- { "_id": 1, "categories":[ { "categoryName": "Automobiles", "categoryId": 1, "catDisplayName": "language1", "subCategories": [ { …
sagar
  • 143
  • 1
  • 2
  • 11
1
vote
1 answer

Mongo get db.serverstatus from casbah

Is there a way to get the results of db.serverStatus() from casbah to handle them? I specifically need the connections, network, metrics fields. Thanks
Ruben
  • 1,673
  • 2
  • 10
  • 10
1
vote
1 answer

MongoDB Casbah Query DSL $exists with $in

Trying to convert the following mongo console query into casbah/scala's DSL. db.campaign.find({ "space.id": { $exists: true, $in: ["123","456"] } }) The best I have come up with has been the following which uses an or instead. $or("space.id"…
atom.gregg
  • 987
  • 8
  • 14
1
vote
1 answer

MongoDB Index ensureIndex Time to Refresh

I created a multi-key compound index via Casbah (Scala library for Mongo): db.collection.ensureIndex(MongoDBObject("Header.records.n" -> 1) ++ MongoDBObject("Header.records.v" -> 1) ++ MongoDBObject("Header.records.l" -> 1)) Then, via the Mongo…
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
1
vote
0 answers

Performance suffers using distinct

Following code gives me some trouble: /** * * finds all distinct values of HybridTypes for the Page Collection */ def findDistinctTypeValues(): List[String] = { //cast all instances from Any to String val coll =…
Stefan Kunze
  • 741
  • 6
  • 15