SCALA 提升 MongoDB MongoRecord 编译错误
我正在尝试为 Scala Lift (2.4) 框架设置一个简单的数据库,
下面是我的 User.scala 模型。
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]
编译时我遇到了 7 个错误,但认为它们都与第一个错误有关:
[error] C:\Lift2.4\scala_29\conference\src\main\scala\code\model\User.scala:7: not found: type MongoRecord
非常感谢任何帮助,我确信我没有导入正确的内容或错过了一些明显的内容。
提前致谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
添加
模型示例
https://github.com /foursquare/rogue/blob/master/src/test/scala/com/foursquare/rogue/QueryTest.scala
对于查询,您可以使用 Rogue:用于查询 MongoDB 的类型安全的 Scala DSL
add
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
MongoRecord
(和MongoMetaRecord
)位于net.liftweb.mongodb.record
中,因此您必须添加,当然还要注意这些包含在 sbt 中。
MongoRecord
(andMongoMetaRecord
) is innet.liftweb.mongodb.record
, so you’ll have to addand of course take care that these are included with sbt.
看看 https://github.com/rohit-tingendab/ks-lift ,它是 Lift + MongoDB 的一个工作启动器。
Have a look at https://github.com/rohit-tingendab/ks-lift, it is a working kick starter for Lift + MongoDB.