Created
April 25, 2012 07:46
-
-
Save vhazrati/2487883 to your computer and use it in GitHub Desktop.
Salat Object
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
import org.scalatest.FunSuite | |
import com.novus.salat.annotations.raw.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 | |
@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="Yahoo") | |
VikasDAO.insert(vikas) | |
val c = VikasDAO.findOne(MongoDBObject("title" -> "Yahoo")) | |
println(c.get) | |
println(Json.generate(c.get)) | |
} | |
} | |
case class Vikas(@Key("_id") id: ObjectId = new ObjectId, title: String) | |
object VikasDAO extends SalatDAO[Vikas, ObjectId](collection = MongoConnection()("mydb")("vikas")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment