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
1 answer

How to get keys of document via casbah?

My document looks like this: { "dynamic_field" : "...", "another_dynamic_field" : "..." "yet_another_dynamic_field" : "..." } "Dynamic field" means that I don't know it's name. So I want to get collection of strings which holds keys of this…
Jeriho
  • 7,129
  • 9
  • 41
  • 57
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

salat serialize Map[Enum,Boolean] type

Hi I would like to serialize/deserealise to DBObject some map with enumeration as key using salat. object MyEnum extends Enumeration { val VAL_ONE, VAL_TWO = Value } case class CanBeStored(a:Enumeration.Value) case class…
Oleg
  • 3,080
  • 3
  • 40
  • 51
1
vote
1 answer

how to add MongoOptions in MongoClient in casbah mongo scala driver

i want to add mongoOptions to MongoClient basically i want to add ConnectionPerHost value its default is 10 i want to increase it to 20 but i am getting errors in the code i have tried with two different ways val SERVER:ServerAddress = { val…
swaheed
  • 3,671
  • 10
  • 42
  • 103
1
vote
1 answer

why 2 connections open when calling MongoClient instance in mongodb

this following code is getting mongodb connection val SERVER:ServerAddress = { val hostName=config.getString("db.hostname") val port=config.getString("db.port").toInt new ServerAddress(hostName,port) } val DATABASE:String =…
swaheed
  • 3,671
  • 10
  • 42
  • 103
1
vote
1 answer

unknown top level operator: $query when using findOne

I had the following function, and wanted to modify it to return only the most recent item: def findOne(filter: DBObject) = collection.findOne(filter) So I tried this: def findOne(filter: DBObject) = { val query = MongoDBObject("$query" ->…
fredley
  • 32,953
  • 42
  • 145
  • 236
1
vote
0 answers

scala mongodb driver: NoSuchMethod

Removing an entity from Database throws an exception. It used to work with the later version of casbah (before 3.x.x). The exception is thrown from the class extending SalatDAO remove(MongoDBObject("_id" -> id)) The exception…
Matej Briškár
  • 599
  • 4
  • 17
1
vote
1 answer

Problems with Salat methods in MongoDB: implicit view & not enough arguments

I'm new with Salat,Casbah and MongoDB. When I've been trying to make a simple method to get all users from db, import DAL.Instances.User.{UserDAO, User} import com.novus.salat._ import com.novus.salat.global._ import…
NikitaAbrosimov
  • 127
  • 1
  • 8
1
vote
1 answer

Casbah 3.0.0 API : Where is the MongoDBObject?

In the getting started tutorial, we use MongoDBObject. But I can't find it in the api. Also, I don't understand how we can run this command : import com.mongodb.casbah.Imports._, can't find it in the API neither...
thomas legrand
  • 493
  • 1
  • 5
  • 16
1
vote
1 answer

What version of Salat/Casbah should I use to connect to Mongo 3.x server?

I am using https://github.com/salat/salat. But it seems that salat is using Casbah 2.7. Our mongo server is 3.0.6. But we are not able to connect and always got this error. Configuration error: Configuration error[Access denied to MongoDB database:…
angelokh
  • 9,426
  • 9
  • 69
  • 139
1
vote
1 answer

Initialize to MongoCursor

I need a var (res in the following) to accept the answer of a find(), i.e. MongoCursor, because I have to have access to my var inside if-conditions (see below). Here is what I am doing: var query = new MongoDBObject() val res = "" if…
wipman
  • 581
  • 6
  • 22
1
vote
1 answer

Querying for a field inside another

I have got this document in myDb.myCollection: "_id" : ObjectId("55fc0ec8666292b85178c180"), "firstname" : "george", "surname" : "abitbol", "data" : { "a" : "secret value", "b" : "4" }, "tags" : "[t]" How do I query for the b field in data…
wipman
  • 581
  • 6
  • 22
1
vote
1 answer

Querying for farthest timestamp

How can I search my mongodb database for the document with the farthest timestamp? Timestamp being a date, ISODate format or not.
wipman
  • 581
  • 6
  • 22
1
vote
0 answers

Storing hash tables on mongodb with fast increment-by updates

I'd like to store word histograms on mongodb very similarly to how a hash table is saved in memory. My input data comes from an ordinary relational database or a .csv file. shape | color | size ************************* circle | blue | 5 square |…
markiz
  • 265
  • 1
  • 7
1
vote
1 answer

remove nested mongo document using Casbah

Given the following data structure: { "_id" : ObjectId("55760212e4b011ee8c72fb1f"), "firstname" : "joe", "lastname" : "blow", "email" : "jb@gmail.com", "sysadmin" : false, "siteadmin" : false, "sites" : [ { "siteId" :…
andyczerwonka
  • 4,230
  • 5
  • 34
  • 57