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

Mongoldb-Casbah: get first match in a collection

I am using Scala and Mongoldb-Casbah and I get some data with: val myData: Traversable[Imports.DBObject] = myCollection.find(query).toTraversable The data returned are a collection like this: [ { _id:"...", prices:[ …
Randomize
  • 8,651
  • 18
  • 78
  • 133
0
votes
1 answer

Multi-field scala/casbah query

I am trying to build a multi-field query. My collection is composed of a lot of documents like the following: { "_id" : ObjectId("5601711160b2abcf7ff24b46"), "id_a" : "43d366a9-a39b-4d49-98ce-369739471b6b", "id_thing" : -1, "data" :…
wipman
  • 581
  • 6
  • 22
0
votes
1 answer

Multiple actors linked to a shared database

The constellation of actors I am working with shares a hierarchical structure. Each of those actors needs to save data in a mongodb database. Rather than creating a link to the database for each actor, I thought it would be better if there was a…
wipman
  • 581
  • 6
  • 22
0
votes
1 answer

Scala + Casbah object mapping good practices

I am looking to implement my DAO access layer using Scala 2.9.x and Casbah. Given my entity is a case class with parameters: case class Price (Id: Option[String], Price: Double, ItemName: String) and my BSON document looks like: { "_id" :…
grimcoder
  • 87
  • 6
0
votes
2 answers

Why is Casbah/MongoDB id index Not Unique?

I'm surprised to see that the _id is not a unique index. I'm providing values for the _id field and MongoDB is creating an index alright but it's not unique. I tried to update it (by creating a new unique index on the _id field) but nothing changed.…
Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219
0
votes
1 answer

Comparing [Ljava.lang.String against Array[String]

I know this may seem like a pretty simple question, but I am new to Scala and could not find a solution online. Basically I am converting an AI based program and all of my data is in JSON format in Mongo. The final little bit of this is a function…
Mitchell Ingram
  • 686
  • 2
  • 11
  • 23
0
votes
1 answer

what is the difference between MongoClient and MongoConnection

i want to know what is the difference between mongoClient and mongoConnection and what is the difference between these two codes serverAddress=new ServerAddress("Localhost",27017) client= MongoClient(serverAddress) testDB =…
swaheed
  • 3,671
  • 10
  • 42
  • 103
0
votes
1 answer

Casbah returns DBObject instead of MongoDBObject

In the official Casbah guide on querying it says findOne Returns an Option - either Some(MongoDBObject) or None However, findOne actually gives me an Option with a plain Some(DBObject) instead: scala> MongoClient("localhost",…
James
  • 209
  • 1
  • 2
  • 7
0
votes
1 answer

Scala Salat deserialization error with @key

I have a case class that looks like this: import com.novus.salat.annotations.raw.Key import org.bson.types.ObjectId case class Users( _id: ObjectId, email: String, password: String, …
invis
  • 1,078
  • 2
  • 14
  • 26
0
votes
1 answer

Which one is better to be used at Http server, Casbah or ReactiveMongo?

I want to start a MongoDB database for my project and I'm a Scala user, but I couldn't find a good comparison between these two Scala frameworks for MongoDB, what are their main differences, supports and other aspects?
Omid
  • 1,959
  • 25
  • 42
0
votes
1 answer

Weird currying of Update function of MongoCollection class of Casbah Mongo driver

As you know casbah mongodb driver has an update function like this : def update [A, B] (q: A, o: B)(implicit arg0: (A) ⇒ DBObject, arg1: (B) ⇒ DBObject) : WriteResult I think i understand currying concept of scala. However, As far as I know this…
0
votes
2 answers

SalatDAO deserialization of typed class with list

I have the following case classes: case class Network(val name : String, val mac : String) case class Field[T](var value : T, var source : String = "") case class Device(var _id : ObjectId = new ObjectId, var device_type :…
Aliza
  • 734
  • 1
  • 10
  • 25
0
votes
1 answer

Casbah (Scala) Generating a query statement with nested conditions ($OR $AND)

Given items: [{ prop1 : "a", prop2 : "b" , prop3, "c",....},....] and patterns:[{ prop1 : "a", prop2 : "Any"},...] I want to create a query to find all patterns that match the given items. The resulting query is of form: ((A or B or C) AND (D or E…
0
votes
1 answer

how to retrieve A scala mutable Set from mongo

I am storing a mutable Set in mongoDB and now i want to retrieve that set from mongo but i am un able to do that maybe i am doing it in a wrong way here is my code class A{ var genreIdSet = scala.collection.mutable.Set[Int]() def…
swaheed
  • 3,671
  • 10
  • 42
  • 103
0
votes
1 answer

How can I elegantly apply a projection to an entire MongoDB collection using Cashbah

Assuming that coll is a MongoCollection, I know that I can select all documents by calling coll.find(), and I know that I can apply a projection to all documents by calling coll.find("_id" $exists true, projection) where projection might be…
Matthias Langer
  • 994
  • 8
  • 22