我当前正在使用
URL :http://localhost:9000/create?name=Ramesh&age=28
方法:获取
路线:GET /创建控制器。MyController.create(名称:字符串,年龄:整数)
导致执行异常如下所示,
[JsResultException: JsResultException(errors:List((,List(JsonValidationError(List(CommandError[code=<unknown>, errmsg=no such cmd: insert, doc: {"ok":0,"errmsg":"no such cmd: insert","bad cmd":{"insert":"persons","documents":[{"name":"Ramesh","age":28}],"ordered":true,"writeConcern":{"w":1,"wtimeout":null}}}]),WrappedArray())))))]
创建Mongo集合为:
def collection: Future[JSONCollection] = database.map(_.collection[JSONCollection]("persons"))
创建操作:
def create(name: String, age: Int) = Action.async {
collection.flatMap(_.insert(Json.obj("name" -> name, "age" -> age))).map { _ =>
Created
}
}
需要帮助我解决这个问题。