Questions tagged [salat]

Salat is a bi-directional Scala case class serialization library that leverages MongoDB's `DBObject` (which uses BSON underneath) as its target format.

The Salat project focuses on speed and simplicity of serializing case classes to and from target formats.

Salat is not a fully-fledged ORM and does not attempt to match the flexibility, compability or functionality of an ORM that would let you define relationships between classes, provide a query language, or serialize/deserialize every collection type known to Java or Scala.

109 questions
1
vote
0 answers

Mongodb Salat, deserialize nested maps

I have a case class with an attribute of type Map[String, Map[String, Int]]. When retrieving the corresponding record from Mongodb, the map is deserialized as Map[String, DbObject]. The exception : Caused by: java.lang.ClassCastException:…
Louis F.
  • 2,018
  • 19
  • 22
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

SalatDAO does not deserialize BasicDBList properly

I have a case class who's one of the properties if of type JValue. During serialization, it gets converted to BasicDBList (regardless of what was it's value, even it if was just a JString - this is odd, but set that aside...) So saving the object to…
Shai
  • 25,159
  • 9
  • 44
  • 67
1
vote
2 answers

Local application connects Mongo through ssh tunnel is not working

I have a ssh tunnel that linked to a remote mongo server. I tried to use this local tunnel with mongo-java-driver in Play server. It throws time-out error. But I can use mongo command line to connect to this tunnel and operate this database without…
angelokh
  • 9,426
  • 9
  • 69
  • 139
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
0 answers

Form submiting with Play/Scala and MongoDB

I am currently writing my first application with scala (2.11), Playframework (2.2.3) and MongoDB (with Salat). Since I dont really know any of them too well I've got a bit of a beginner problem: I can't submit data from a form. I am not really sure…
Markus
  • 1,565
  • 6
  • 26
  • 57
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
1
vote
1 answer

scala salat objectid is changing after inserting into database

I've a problem with Salat library in scala - I've got a case class Item: case class Item(_id: ObjectId = new ObjectId, var name: String, var active: Boolean) extends WithId { override def id: Option[ObjectId] = Some(_id) } The _id field is…
Marcin
  • 505
  • 8
  • 20
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
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
0 answers

Find a file in gridfs via md5

I'm trying to find a file in gridFS via the md5 hash, but don't get it to work. My app is a Play application, therefore I use play salat plugin. This is what I'm doing: val Images = gridFS("Images") val image = new File("
schub
  • 912
  • 1
  • 8
  • 26
1
vote
2 answers

Creating a case class for an embedded MongoDB Array with Salat and Scala

I am trying to figure out how to properly serialize a document from MongoDB in my Scala project. The problem I have here is I'm not sure what to do when I have an Array field in my document and how to treat it in Scala. Here's what the document…
randombits
  • 47,058
  • 76
  • 251
  • 433
1
vote
1 answer

implicit json read and writes for lists

I am following the following example https://github.com/leon/play-salat/tree/master/sample . In my data model I have lists and I tried to adopt the model to that. I get the following compilation errors: [error]…