SCALA Lift MongoDB MongoRecord compilation errors
I'm attempting to setup a simple DB for the Scala Lift (2.4) framework
Below is my User.scala model.
package code.model
import net.liftweb.mongodb._
import net.liftweb.json.JsonDSL._
import com.mongodb._
class User private() extends MongoRecord[User] with ObjectIdPk[User] {
def meta = User
object name extends StringField(this, 50)
object level extends IntField(this)
}
object User extends User with MongoMetaRecord[User]
When compiling I get 7 errors, but think they are all related to this first one:
[error] C:\开发者_如何学编程Lift2.4\scala_29\conference\src\main\scala\code\model\User.scala:7: not found: type MongoRecord
Any help is much appreciated, I'm sure I'm not importing something right or have missed something obvious.
Thanks in advance
add
import net.liftweb.mongodb.record._
import net.liftweb.mongodb.record.field._
import net.liftweb.record.field._
import net.liftweb.record._
example of model
https://github.com/foursquare/rogue/blob/master/src/test/scala/com/foursquare/rogue/QueryTest.scala
For queries, you can use Rogue: A Type-Safe Scala DSL for querying MongoDB
import net.liftweb.mongodb.record._
MongoRecord
(and MongoMetaRecord
) is in net.liftweb.mongodb.record
, so you’ll have to add
import net.liftweb.mongodb.record._
and of course take care that these are included with sbt.
Have a look at https://github.com/rohit-tingendab/ks-lift, it is a working kick starter for Lift + MongoDB.
精彩评论