使用 Play Morphia MongodDb 插件时如何保存模型?
我正在使用 morphia 插件来玩框架,我的代码是在 scala 中。 该插件的文档:
http://www.playframework.org/modules/morphia -1.2.1beta6/home
我找不到任何关于如何在 mongodb 数据库中保存模型实例的文档,例如:
val user = new User(cid: "iyoiyoiy97097097")
// how to save now?
域模型是:
@Entity
class User(@Required val cid: String, val isAdmin: Boolean = false, @Required val dateJoined: DateTime = new DateTime() ) extends Model
此查询是否正确:
val user = User.filter("cid", "123123123sdfsdf").get()
请注意,人们经常将 Morphia 与 Play 混淆与它无关的框架。 Play 框架 Morphia 插件将其联系起来。但现在使用我在我的例子中使用的插件时的 CRUD 操作与仅使用 Morphia 而不使用该插件时不同。
我用的是play 1.2.2RC2。和吗啡插件 morphia-1.2.1beta6
I am using morphia plugin for play framework and my code is in scala.
The documentation of this plugin:
http://www.playframework.org/modules/morphia-1.2.1beta6/home
I could not find any documentation regarding how do I save a model instance in mongodb databse like:
val user = new User(cid: "iyoiyoiy97097097")
// how to save now?
domain model is:
@Entity
class User(@Required val cid: String, val isAdmin: Boolean = false, @Required val dateJoined: DateTime = new DateTime() ) extends Model
Is this query correct:
val user = User.filter("cid", "123123123sdfsdf").get()
Please note that people often confuse Morphia with Play framework with which it has nothing to do. Play framework Morphia plugin ties this up. But now CRUD operations are different when using the plugin which I am using in my case as opposed to when using just Morphia without the plugin.
I using play 1.2.2RC2. and morphia plugin morphia-1.2.1beta6
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定 Scala,但对于 Java,它只是
为了验证:
I am not sure about Scala, but with Java it is simply
or for validation: