salat

Still can't run multiple tests against play FakeApp with Salat / Casbah

霸气de小男生 提交于 2019-12-06 08:10:08
问题 I thought I had fixed the problem temporarily, but it turns out I am still having problems. I am trying to create some specs2 tests for my models layer, I would like to insert some dummy object, and then run some queries to make sure data comes out as expected. Here is what my simple test looks like: class ModelSpec extends Specification { override def is = args(sequential = true) ^ super.is object FakeApp extends FakeApplication() running(FakeApp){ println("set up database") val newUser =

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

一笑奈何 提交于 2019-12-05 07:23:50
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 that consists of someRelatedId+email and have MongoDB use that instead of the default ObjectId. From the documentation I get the feeling it is possible, but I'm still groping around for a working solution. This is in a large part due to my lack of proficiency with Scala itself, I'm sure. Update: I have a working solution now, but I'm still wondering if

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

别说谁变了你拦得住时间么 提交于 2019-12-04 14:51:27
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 Tweet to User. In MongoDB, this wouldn't necessitate a DBRef , storing the user's ObjectId would be sufficient. Both in Subset and Salat this would result in these case classes: case class Tweet(_id: ObjectId, content: String, userId: ObjectId) case class User(_id: ObjectId, name: String) So there's no guarantee that the ObjectId in Tweet actually

Still can't run multiple tests against play FakeApp with Salat / Casbah

有些话、适合烂在心里 提交于 2019-12-04 14:46:56
I thought I had fixed the problem temporarily, but it turns out I am still having problems. I am trying to create some specs2 tests for my models layer, I would like to insert some dummy object, and then run some queries to make sure data comes out as expected. Here is what my simple test looks like: class ModelSpec extends Specification { override def is = args(sequential = true) ^ super.is object FakeApp extends FakeApplication() running(FakeApp){ println("set up database") val newUser = User( email = "wfbarksdale@gmail.com", username = "weezybizzle", password = "nutterbutter") User.save

How to update object in Mongo with an immutable Salat case class

怎甘沉沦 提交于 2019-12-02 10:02:08
问题 I'm working on a project with Scala, Salat, Casbah, Mongo, Play2, BackboneJS... But it's quite a lot of new things to learn in the same time... I'm ok with Scala but I find my code crappy and I don't really know what's the solution to improve it. Basically my usecase is: A MongoDB object is sent to the browser's JS code by Play2 The JS code update the object data (through a Backbone model) The JS send back the the updated JSON to the server (sent by Backbone save method, and received by Play

How to update object in Mongo with an immutable Salat case class

无人久伴 提交于 2019-12-02 04:06:11
I'm working on a project with Scala, Salat, Casbah, Mongo, Play2, BackboneJS... But it's quite a lot of new things to learn in the same time... I'm ok with Scala but I find my code crappy and I don't really know what's the solution to improve it. Basically my usecase is: A MongoDB object is sent to the browser's JS code by Play2 The JS code update the object data (through a Backbone model) The JS send back the the updated JSON to the server (sent by Backbone save method, and received by Play with a json bodyparser) The JSON received by Play should update the object in MongoDB Some fields