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 isAdmi开发者_如何转开发n: 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
I am not sure about Scala, but with Java it is simply
user.save();
or for validation:
user.validateAndSave();
精彩评论