我正在學習如何使用斯卡拉,MongoDB的好戲框架一起,和我在這是這裏位於一個示範項目,一直在尋找:https://github.com/jonasanso/play-reactive-mongo-db某對象插入Mongo的數據庫使用Scala的ReactiveMongo司機
然而,我不明白create()
方法中的語法。沒有使用關鍵字yield
可以使用另一種方式編寫它嗎?我仍然在學習Scala,我不明白這種方法是如何工作的。
def create(name: String, population: Int) = Action.async {
for {
cities <- citiesFuture
lastError <- cities.insert(City(name, population))
} yield
Ok("Mongo LastError: %s".format(lastError))
}
先閱讀[文件](HTTP:// reactivemongo。 org/releases/0.11/documentation/index.html) – cchantep