PageRenderTime 57ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/scala/salat/App.scala

https://github.com/tc/casbah-salat-maven-example
Scala | 28 lines | 19 code | 9 blank | 0 comment | 0 complexity | 6ca04710fb93f70effbf2f38c4405766 MD5 | raw file
  1. package salat
  2. import com.novus.salat._
  3. import com.novus.salat.dao._
  4. import com.novus.salat.global._
  5. import com.mongodb.casbah.Imports._
  6. case class Employee(_id:ObjectId = new ObjectId, name: String, age: Option[Int]=None, annual_salary: Option[BigDecimal]=None)
  7. object EmployeeDAO
  8. extends SalatDAO[Employee, ObjectId](collection = MongoConnection()("salat_test")("employees"))
  9. object App{
  10. def main(args:Array[String]){
  11. val employee = Employee(name="Foo")
  12. val id = EmployeeDAO.insert(employee)
  13. println("Inserted id:" + id)
  14. val found = EmployeeDAO.findOne(MongoDBObject("name" -> "Foo"))
  15. println("Found record for name ->Foo:" + found)
  16. val dbo = grater[Employee].asDBObject(employee)
  17. println("Converted DBObject:" + dbo)
  18. }
  19. }