Created
April 26, 2012 09:28
Revisions
-
Vikas Hazrati created this gist
Apr 26, 2012 .There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ import org.scalatest.FunSuite import com.novus.salat.annotations.Key import org.bson.types.ObjectId import org.specs2.specification.BeforeAfter import org.scalatest.BeforeAndAfter import com.novus.salat.dao.SalatDAO import com.mongodb.casbah.MongoConnection import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner //import com.novus.salat.global._ import com.mongodb.casbah.Imports._ import com.codahale.jerkson.Json import com.twelvekd.aggregator.server.utils.custom_type_hint._ @RunWith(classOf[JUnitRunner]) class ExperienceOfferRecordTest extends FunSuite with BeforeAndAfter { test("Check that Salat saves the object to MongoDB with single id") { val vikas = Vikas(title="HipHopppp") VikasDAO.insert(vikas) } } case class Vikas(title: String) object VikasDAO extends SalatDAO[Vikas, ObjectId](collection = MongoConnection()("12kd")("vikas")) This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ import com.novus.salat._ import com.mongodb.casbah.Imports._ /** * We are overriding the global context of Salat to change the default behaviour of * typehinting. See https://github.com/novus/salat/wiki/CustomContext */ package object custom_type_hint { implicit val ctx = new Context { /** name of the overriding context */ val name = "Context-TypeHintNever" /** override the default typehinting strategy */ override val typeHintStrategy = NeverTypeHint } // Renaming the default _id to id ctx.registerGlobalKeyOverride(remapThis = "_id", toThisInstead = "id") }