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

Why do my MongoDB simultaneous $push updates fail?

I'm performing a number of updates of the form update( { "uuid": someUuid, "revision.versionNumber": someVersionNumber}, { "$set": { "meta.someId": someId }, "$push": { "meta.someMessages": someMessage } } ) occasionally I see when this is…
Bobby
  • 18,217
  • 15
  • 74
  • 89
8
votes
2 answers

How to query a Array[String] for a regexp match?

i try to query MongoDB via Casbah for a field that is a array of strings with a regexp. For example: I have a Maschine with a list of ips, that are stored as string in the fields ips. Now i want to search for all machines that have the subnet…
Odo
  • 209
  • 1
  • 12
8
votes
2 answers

Play framework Leon Salat Model Form Mapping

I'm creating a scala application using Play framework and mongoDB. I manage to have the connections up using Leon Play-Salat. I have a model case class Person( id: ObjectId = new ObjectId, fname: String, mname: String, lname: String ) In my…
William
  • 395
  • 1
  • 5
  • 17
7
votes
2 answers

How to test methods based on Salat with ScalaTest

I'm writing a web-app using Play 2, Salat (for mongoDB bindin). I would like to test some methods, in the Lesson Model (for instance test the fact that I retrieve the right lesson by id). The problem is that I don't want to pollute my current DB…
TeaBough
  • 165
  • 6
6
votes
1 answer

What is the best way to deal with compsite keys when using Salat with MongoDB?

I'm using Salat with MongoDB and I'm trying to convert to natural keys to avoid duplicates in the database. The case class I'm using looks somewhat like: case class Foo(someRelatedId: String, email: String ...) I would like to add a natural key…
iwein
  • 25,788
  • 10
  • 70
  • 111
5
votes
2 answers

Salat not deserializing collections that map to Option[Set[A]]

I asked this question in scala-salat Google group, but no response there for a few days, hence trying here. I have a case class which has a collection wrapped in an Option. case class SomeClass( var name:Option[String]=None, var…
lobster1234
  • 7,679
  • 26
  • 30
5
votes
2 answers

How to retrieve all objects in a Mongodb collection including the ids?

I'm using Casbah and Salat to create my own Mongodb dao and am implementing a getAll method like this: val dao: SalatDAO[T, ObjectId] def getAll(): List[T] = dao.find(ref = MongoDBObject()).toList What I want to know is: Is there a better way…
uzilan
  • 2,554
  • 2
  • 31
  • 46
4
votes
1 answer

Format nullable Seq or List of objects with Play Json and Salat

I want to convert a json to Salat model. I am using Play 2.X Scala Json. I couldn't find any documentations to format nullable Seq. According to https://github.com/novus/salat/wiki/SupportedTypes, I can't use Option[Seq] Or Option[List]. The…
angelokh
  • 9,426
  • 9
  • 69
  • 139
4
votes
0 answers

Why in Salat does the value of grater[BigThing].asDBObject(v) has nested fields turned into Array's?

Here are the imports I am using: import com.novus.salat._ import com.novus.salat.global.ctx import net.liftweb.json._ import com.mongodb.casbah.Imports._ I have two case classes: case class BigThing (thing: Thing ) case class Thing(x:Int,…
4
votes
2 answers

Mapping MongoDB documents to case class with types but without embedded documents

Subset looks like an interesting, thin MongoDB wrapper. In one of the examples given, there are Tweets and Users. However, User is a subdocument of Tweet. In classical SQL, this would be normalized into two separate tables with a foreign key from…
Marius Soutier
  • 11,184
  • 1
  • 38
  • 48
4
votes
2 answers

Why do i need Scala compiler at runtime? (Play2/Salat with Scalap dependency)

I'm using Scala / Mongo / Casbah / Salat / Play2 and when i try to use Salat it seems it has a dependency to Scalap. It works fine when running the application with play run but with play start i get the following stack: [info] application - Can't…
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
4
votes
1 answer

scala & mongoDB - how to count records with salat?

Is it possible to issue a count() query, with several conditions, using salat library? right now I'm just doing something like def countByPoll(pollId: String, option: Int): Int = { dao.find( MongoDBObject("pollId" -> pollId, "option" ->…
opensas
  • 60,462
  • 79
  • 252
  • 386
3
votes
2 answers

Define custom serialization with Casbah / Salat - or delegate serialization to member?

I'm in the process of learning Scala for a new project having come from Rails. I've defined a type that is going to be used in a number of my models which can basically be thought of as collection of 'attributes'. It's basically just a wrapper for a…
Russell
  • 12,261
  • 4
  • 52
  • 75
3
votes
1 answer

How to perform SQL like "IN" query using Salat for mongodb?

I have many records with below structure saved in mongodb. case class User(_id:ObjectId = new ObjectId, email:String, role:String, employeeID:Int, createdOn:DateTime) How can I execute the "IN" like query on mongodb using salat? e.g. val data =…
pawank
  • 113
  • 7
3
votes
1 answer

Casbah/Salat: How to query a field that a part of a string is contained?

i try to write a query with Casbah and Salat to query a field that it includes parts of a name. I tried to use a regular expression like this (inside a SalatDAO): val regexp = (""".*"""+serverName+""".*""").r val query = "serverName" -> regexp val…
Odo
  • 209
  • 1
  • 12
1
2 3 4 5 6 7 8