在Play框架中连接数据库

时间:2016-09-27 06:36:08

标签: json mongodb scala play-reactivemongo

我做了以下事情

=> controllers.Application

object Application extends Controller {

  val studentForm = Form(

    mapping(

      "FirstName" -> text,

      "MiddleName" -> text,

      "LastName" -> text,

      "RollNumber" -> number,

      "TemporaryAddress" -> text,

      "PermanentAddress" -> text,

      "Faculty" -> text,

      "Section" -> text,

      "ContactNumber" -> number,

      "Email" -> text

    )(StudentInfo.apply)(StudentInfo.unapply)

  )

  def saveForm = Action {/* implicit request =>

    studentForm.bindFromRequest.fold(

      errors => (BadRequest("Error")),

      res => */ Ok(views.html.forms(studentForm))


    }


   }

=> models

package models


import play.api.libs.json.Json


/**

  * Created by milan on 9/26/16.

  */

case class StudentInfo (

  FirstName: String,

  MiddleName:String,

  LastName:String,

  RollNumber:Int,

  TemporaryAddress:String,

  PermantAddress:String,

  Faculty:String,

  Section:String,

  ContactNumber:Int,

  Email:String)

  {


   }
object StudentInfo {

  implicit val info = Json.format[StudentInfo]


}

=> routes

GET  /forms                               controllers.Application.saveForm

这给出了form.Now我需要连接数据库而不使用视图,即

与json.And我需要使用Mongodb和reactiveMongo.Can任何人帮助我

这样做吗?

0 个答案:

没有答案
相关问题