0
我正在使用Play-salat插件和我正在制作的应用程序! 2.0 scala。解决方案DuplicateKey:E11000与Play重复键错误索引! 2.0框架
我得到的重复键错误,编译点这里的错误:
object Post extends ModelCompanion[Post, ObjectId]
我已阅读,这可以固定在PHP here做未设置的,请告诉我如何与做到这一点玩。
我能够在我的数据库中张贴一次,当我再次尝试时,我得到的错误。
def save = Action { implicit request =>
postForm.bindFromRequest.fold(
formWithErrors => BadRequest(html.newpost(formWithErrors)),
post => {
Post.insert(post)
Home
}
)
}
val postForm = Form(
mapping(
"_id" -> ignored(new ObjectId()),
"title" -> nonEmptyText,
"content" -> nonEmptyText,
"posted" -> date("yyyy-MM-dd"),
"modified" -> optional(date("yyyy-MM-dd")),
"tags" -> nonEmptyText,
"categories" -> nonEmptyText,
"userId" -> nonEmptyText
)(Post.apply)(Post.unapply)
)