Created
January 18, 2012 18:15
-
-
Save rktoomey/1634619 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.novus.salat.test.model | |
| import com.novus.salat._ | |
| import com.novus.salat.annotations._ | |
| import com.mongodb.casbah.Imports._ | |
| case class Bar(email: String) | |
| case class Foo[X](jobId: String, bar: Bar, x: Set[X] = Set.empty) { | |
| @Persist @Key("_id") val guid = jobId + bar.email | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| salat:0:0.0.8-SNAPSHOT> project salat-core | |
| [info] Set current project to salat-core (in build file:/home/rose/workspace/salat/) | |
| salat-core:0:0.0.8-SNAPSHOT> test:console | |
| [info] Formatting 40 Scala sources {file:/home/rose/workspace/salat/}salat-core(test) ... | |
| [info] Reformatted 1 Scala source {file:/home/rose/workspace/salat/}salat-core(test). | |
| [info] Compiling 40 Scala sources to /home/rose/workspace/salat/salat-core/target/scala-2.9.1/test-classes... | |
| [info] Starting scala interpreter... | |
| [info] | |
| Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26). | |
| Type in expressions to have them evaluated. | |
| Type :help for more information. | |
| scala> import com.novus.salat.test.model._ | |
| import com.novus.salat.test.model._ | |
| scala> import com.novus.salat.global._ | |
| import com.novus.salat.global._ | |
| scala> import com.novus.salat._ | |
| import com.novus.salat._ | |
| scala> val bar = Bar(email = "[email protected]") | |
| bar: com.novus.salat.test.model.Bar = Bar([email protected]) | |
| scala> val foo = Foo(jobId = "xyz", bar = bar, x = Set(1, 2, 3)) | |
| foo: com.novus.salat.test.model.Foo[Int] = Foo(xyz,Bar([email protected]),Set(1, 2, 3)) | |
| scala> val dbo = grater[Foo[Int]].asDBObject(foo) | |
| dbo: com.mongodb.casbah.Imports.DBObject = { "_typeHint" : "com.novus.salat.test.model.Foo" , "jobId" : "xyz" , "bar" : { "_typeHint" : "com.novus.salat.test.model.Bar" , "email" : "[email protected]"} , "x" : [ 1 , 2 , 3] , "_id" : "[email protected]"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment