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
0
votes
2 answers

Salat MongoDB DAO findOneById how to

I have recently started using Scala, Akka and the Salat serialization library for MongoDB. Now I am trying to set up a SalatDAO for objects that look like this: import com.novus.salat.annotations._ case class MyObject(@Key("_id) compId:…
Giovanni Botta
  • 9,626
  • 5
  • 51
  • 94
0
votes
1 answer

With Scala Salat (using mongodb casbah), how to store and load binary data?

I have a product case class defined in the way Salat expects. case class Product(@Key("product_id") productId: String, @Key("png_image_binary") pngImageBinary: ???) How can I add pngImageBinary so I can store this as a binary…
Phil
  • 46,436
  • 33
  • 110
  • 175
0
votes
1 answer

Scala Macro Annotations - Why doesn't my class appear to be updated when I use it as a type parameter?

I used Eugene Burmako's macro annotation example from Macro Paradise (thanks Eugene!) and modified here it to add a val to an empty class here. As an instance, I can call the new val as expected. But when I try to use the updated class as a type…
Julian Peeters
  • 853
  • 1
  • 6
  • 19
0
votes
1 answer

MongoDB-Scala-Play: Write/Read composite Id

I've just ported my application to Play 2.2 and modified some code to use the latest version of SecureSocial - I've seen case class UserId has been renamed to IdentityId. Well, I'm able to register a new user... and the data is saved to MongoDB…
j3d
  • 9,492
  • 22
  • 88
  • 172
0
votes
1 answer

Lazyloading collection in play-salat

Is it possible to load a collection lazy with Sala? e.g. I have an object like Example 1 (in this case, the whole user list is loaded when retrieving the object) case class Test( @Key("_id") _id: ObjectId = new ObjectId, name: String, …
pichsenmeister
  • 2,132
  • 4
  • 18
  • 34
0
votes
1 answer

Feedback on Versioning Objects with Salat

I'm trying to achieve the following: basically just coping a mongodb document and add a timestamp field to it in order to reconstruct the order in which the document was altered and in case if needed to restore these entries. My approach is the…
Stefan Kunze
  • 741
  • 6
  • 15
0
votes
1 answer

mongodb distinct values of a row in a generic fashion

given the following code: def findDistinctTypeValues(): Set[String] = { //cast all instances from Any to String val coll = dao.collection.distinct("hybridType") map (_.asInstanceOf[String]) coll.toSet } How would one do this in a…
Stefan Kunze
  • 741
  • 6
  • 15
0
votes
1 answer

Salat - how to lookup remapped values from a context

I'm stuck and in need of your help. Assuming I have this context to work with the play framework: package object mongoContext { implicit val context = { val context = new Context { val name = "global" override val…
Stefan Kunze
  • 741
  • 6
  • 15
0
votes
1 answer

Salat Dao - not acessible via JUnit

I have the following class: package backend.link import org.bson.types.ObjectId import com.novus.salat.annotations.raw.Salat import com.novus.salat.dao.ModelCompanion import com.novus.salat.dao.SalatDAO import model.hybrid.HybridEntity import…
Stefan Kunze
  • 741
  • 6
  • 15
0
votes
1 answer

How to use a case class to deserialize an array of json objects to List[Map[String,String]]

I am having trouble deserializing my case class. Although the serialization works great I can't get back the case class with the correct type for some reason. This is my case class: case class Team( id: ObjectId = new ObjectId, teamType: String…
whitehead1415
  • 435
  • 4
  • 14
0
votes
1 answer

How do I get JSON string from Mongo db using Play (and Salat)?

How do I get the plain JSON from Mongo DB using Play? (Currently I'm accessing Mongo with Salat because it's the only way I have found yet). I have currently: MyEntry.findAll() Where findAll returns a SalatMongoCursor - I can call something on it…
User
  • 31,811
  • 40
  • 131
  • 232
0
votes
2 answers

How to get None Option from salatDAO when mongodb gives error

import com.escalatesoft.subcut.inject._ import com.mongodb.casbah.Imports._ import com.novus.salat._ import com.novus.salat.global._ import com.novus.salat.dao._ case class User(_id: ObjectId = new ObjectId, email: String, password: String) class…
whitehead1415
  • 435
  • 4
  • 14
0
votes
2 answers

Sort by multiple attributes with Salat for MongoDB

I try to perform a query on a MongoDB with Salat. The query should sort the result set by two attributes. I haven't found any examples. Sorting with a single MongoDBObject works as expected. val results = dao .find(MongoDBObject.empty) …
Patrick Hammer
  • 1,172
  • 14
  • 25
0
votes
1 answer

How do I parse DBObject to case class object using subset2?

Does anyone know how to parse DBObject to case class object using subset2 ? Super concise documentation doesn't help me :( Consider following case class case class MenuItem(id : Int, name: String, desc: Option[String], prices: Option[Array[String]],…
expert
  • 29,290
  • 30
  • 110
  • 214
0
votes
1 answer

How to specify salat DAO model for nested list of mixed type?

I have data coming back from MongoDB that looks like this: > db.foo.findOne() [ { "_id" : "some string", "bar" : [ [ 14960265, 0.5454545454545454 ], [ …
mrjf
  • 1,117
  • 1
  • 12
  • 22