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

Can not connect with Casbah but it works with ReactiveMongo

I have an issue connecting to my mongo database with Casbah and it works fine with ReactiveMongo. Here is the code used with Casbah: val client = MongoClient(MongoClientURI("my_uri")) and with ReactiveMongo:…
mravey
  • 4,380
  • 2
  • 21
  • 31
1
vote
3 answers

play framework with mongodb

I am using mongo with play framework with "reactivemongo", That makes an async bridge between mongo connection and programm. For standalone projects I always use casbah lib - it has more native syntax (sometimes using of Futures in each request is…
Oleg
  • 3,080
  • 3
  • 40
  • 51
1
vote
1 answer

efficient way to transform a playframework JsValue to a MongoDBObject

I'm receiving an JSON graph (payload) from the client, so at the web api I get a JsValue. I simply want to take that, decorate it with a couple of fields and store it in Mongo. Something like this: case class Plan(_id: ObjectId, name: String,…
andyczerwonka
  • 4,230
  • 5
  • 34
  • 57
1
vote
1 answer

apache spark stand alone connecting to mongodb with scala using casbah

i would like to perform a Apache Spark map-reduce on 5 files and output them to mongodb. I would prefer not using HDFS since NameNodes are a single point of failure (http://wiki.apache.org/hadoop/NameNode). A. Is it possilbe to read multiple files…
1
vote
2 answers

How to convert org.bson.types.ObjectId to String during marshalling?

Looks like I have to write a serializer/deserializer to fix this, but not exactly sure how. I see several examples using liftweb framework, but not without it. Any help on how to get this working? Registration Model package model import…
Srini K
  • 3,315
  • 10
  • 37
  • 47
1
vote
1 answer

How to insert into MongoDB from actor using Casbah?

Assumptions: MongoDB is running at localhost:27017 This project is modeled after https://github.com/sap1ens/akka-microservice. Please refer to it if there is not enough information below to help. If it gets too confusing, I can add code from other…
Srini K
  • 3,315
  • 10
  • 37
  • 47
1
vote
1 answer

Casbah $nearSphere dont support $maxDistance

I have 2dSphere index on bikes.loc field My following query works fine in mongo shell db.bikes.find({ fromDate: { $lte: ISODate("2014-10-11T00:01:00Z") }, toDate: { $gte: ISODate("2014-10-12T05:05:00Z") }, bikeType: "Road", loc: { $near:…
komal dedhia
  • 217
  • 1
  • 3
  • 8
1
vote
0 answers

Ignoring extra data in JSON using grater.fromJson

I am trying to use salat to import some JSON documents into my case class model. Basically, I'm doing this; grater[RootModel].fromJSON(json) I have implemented the case class hierarchy for the data I care about, but the JSON doc I get back often…
XeroxDucati
  • 5,130
  • 2
  • 37
  • 66
1
vote
1 answer

How to customize serialization behavior without annotations in Salat?

I'm using Salat library to serialize objects to be stored in MongoDb via Casbah. Sometimes I need to tune little bit how fields will be serialized, and Salat's Annotations is a pretty convenient way to do it. BUT, Is there any way to describe…
alekseevi15
  • 1,732
  • 2
  • 16
  • 20
1
vote
1 answer

Error while including casbah dependencies

I am facing problem in getting started with casabah to integrate scala and mongoDb. I am using Spring Tool Suite(STS) and imported the following jar files…
optimus
  • 77
  • 1
  • 6
1
vote
1 answer

MongoDBObject not being added to inside of an rrd foreach loop casbah scala apache spark

Ok guru's, i've got a problem that doesnt make much sense to me. I am stuck trying to save an object to mongodb that looks like such (roughly) {data:[baseball:[{timestamp (essentially):tweet},{timestamp: another tweet}] …
Joe Lane
  • 67
  • 1
  • 6
1
vote
1 answer

Casbah multidimensional Array - Retrieve from DB

I have a case class with a 2-dimensional array stored in a MongoDB, because Salat does not support Arrays I'm trying to write my own converters. case class Matrix(id: String, matr: Array[Array[Int]]) implicit def toDBObject(m: Matrix) =…
user4007301
  • 67
  • 2
  • 9
1
vote
1 answer

How to read back a datetime as UTC in MongoDB / Casbah?

I'm storing times in UTC at a MongoDB server. When reading them back, using: import org.joda.time.DateTime ... val time_utc: DateTime = dbo.get("time_utc").asInstanceOf[DateTime] I get times converted to local time zone of the server. How should I…
akauppi
  • 17,018
  • 15
  • 95
  • 120
1
vote
2 answers

Casbah MongoDB, how to both add and remove values to an array in a single operation, to multiple documents?

After searching, I was unable to figure out how to perform multiple updates to a single field. I have a document with a "tags" array field. Every document will have random tags before I begin the update. In a single operation, I want to add some…
user1170533
  • 79
  • 1
  • 5
1
vote
1 answer

Using MongoDBObject Query Builder with Salat

I am attempting to provide an API to search a MongoDB collection on various criteria, including a full-text search. Since this is a Scala project (in Play FWIW), I am using Salat, an abstraction around Casbah. The following code works…
Vidya
  • 29,932
  • 7
  • 42
  • 70