未解决的参考:addcriteria(kotlin)
我正在尝试在Kotlin编写一些基本的MongoDB自定义查询。
我几乎到处都看到人们使用方法addCriteria
:
val query: Query = Query()
query.addCriteria(Criteria.where("field1").exists(true)))
但是,查询中似乎没有添加添加标准:org.springframework.data.data.mongodb.repository.query.query
我很困惑。除了使用此方法外,除了使用Spring Data以外,还找不到有关如何在Kotlin中编写自定义MongoDB查询的任何解释。
I am trying to write some basic MongoDB custom queries in Kotlin.
I've seen nearly everywhere that people use a method addCriteria
:
val query: Query = Query()
query.addCriteria(Criteria.where("field1").exists(true)))
But it seems there is no method addCriteria in Query which I use: org.springframework.data.mongodb.repository.Query
I am very confused. Cannot find any explanations on how to write custom MongoDB queries in Kotlin with Spring Data except using this method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,我非常接近问题的解决方案。我确实使用了错误的查询,尽管它的路径看起来真的很合乎逻辑。我需要这个:
org.springframework.data.mongodb.core.query.query.query
。我使用
org.springframework.data.mongodb.repository.query.query
是查询注释,而不是类So, I was very close to the problem's solution. I really used wrong Query, despite it's path looks really logical. I needed this one:
org.springframework.data.mongodb.core.query.Query
.I used
org.springframework.data.mongodb.repository.Query
, which is Query annotation, not the class