SCALA 提升 MongoDB MongoRecord 编译错误

发布于 2024-12-06 23:42:49 字数 670 浏览 3 评论 0原文

我正在尝试为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

自找没趣 2024-12-13 23:42:49

添加

import net.liftweb.mongodb.record._ 
import net.liftweb.mongodb.record.field._ 
import net.liftweb.record.field._ 
import net.liftweb.record._ 

模型示例
https://github.com /foursquare/rogue/blob/master/src/test/scala/com/foursquare/rogue/QueryTest.scala
对于查询,您可以使用 Rogue:用于查询 MongoDB 的类型安全的 Scala DSL

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

澉约 2024-12-13 23:42:49
import net.liftweb.mongodb.record._
import net.liftweb.mongodb.record._
魂归处 2024-12-13 23:42:49

MongoRecord (和 MongoMetaRecord)位于 net.liftweb.mongodb.record 中,因此您必须添加

import net.liftweb.mongodb.record._

,当然还要注意这些包含在 sbt 中。

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.

任谁 2024-12-13 23:42:49

看看 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文