- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我希望在查询注释中使用 MongoRepository 来使用正则表达式。到目前为止我找到的唯一信息是一个中文帖子,但没有解释它是如何工作的,我不确定是否是我要找的。
@Query("{ 'name':{'$regex':?2,'$options':'i'}, sales': {'$gte':?1,'$lte':?2 }}")public Page findByNameAndAgeRange(String name,double ageFrom,double ageTo,Pageable page);
有人知道是否可以在查询中使用特定的正则表达式吗?
问候。
最佳答案
i toggles case insensitivity, and allows all letters in the pattern to match upper and lower cases.
在 MongoDB docs 中阅读有关 $regex 的更多信息.
在您的查询中,您似乎混淆了参数顺序(名称正则表达式中的?2)。我认为应该是:
@Query("{ 'name':{$regex:?0,$options:'i'}, sales': {$gte:?1,$lte:?2}}")
public Page findByNameAndAgeRange(String name,double ageFrom,double ageTo,Pageable page);
关于java - spring MongoRepository 查询正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16729728/
我有一个看起来像这样的文档 @Document public @Data class Note { @Id private String noteId; private Str
我正在尝试为模型“文档”实现一个 QueryDslMongoRepository @QueryEntity @Document(collection="currentDocuments") publi
在尝试将继承与 MongoRepository for C# 结合时,我遇到了序列化错误。 真正奇怪的是它可以在很短的时间内工作,但是在说重建或其他事情之后它就失败了。如果我删除该集合并创建一个新集合
我正在尝试使用 embeddedMongoDb 测试我的 spring 数据 mongodb 存储库,它们是从 MongoRepository 扩展的接口(interface).像这样tutorial
我正在尝试使用 mongo-spring-boot 实现 findAllByUUID,但没有运气。我有什么: public interface CarMatchRepository extends M
我有一个 MongoDB 集合,其中包含具有以下字段的文档: 日期(日期对象) 报价类型(str) 我想使用 MongoRepository 编写一个方法来查找日期范围内的所有文档,并且 OfferT
我正在尝试编写一个函数来更新 mongodb 集合中的某些特定字段,我尝试了 stackoverflow 旧帖子中的一些解决方案,但没有成功,在我添加实现 CollaboratorsRepositor
我使用 SpringBoot、Spring Data 和 MongoRepository 来存储和检索对象。 使用 MongoRepository 时,有没有办法提供自定义 json 反序列化器(最好
我在从 Pageable 排序时遇到问题使用MongoRepository中的地理空间方法 使用以下代码,当 requestVo.page 为 0 时,我能够检索第一个 requestVo.per_p
我正在使用 Spring Boot 1.5.6。特别是,我正在使用 Spring Boot Data MongoDB用于连接 MongoDB。 假设我有这个MongoRepository public
我希望在查询注释中使用 MongoRepository 来使用正则表达式。到目前为止我找到的唯一信息是一个中文帖子,但没有解释它是如何工作的,我不确定是否是我要找的。 @Query("{ 'name'
我正在创建一个 MongoRepository 并且需要创建一个计数查询。有人可以提供一个示例,说明通过 SpringData MongoDB MongoRepository 工具执行此操作的最佳方法
我正在使用 Mongo Repository 与 mongo 数据库对话。 这是我的连接字符串。 然后我像这样使用它: using System; using System.Lin
我有一个 Spring 项目和一个 MongoRepository。 MongoRepository 是一个扩展 MongoRepository 的接口(interface),就像 JPA 一样。 如
我正在使用带有 querydsl 的 mongodb 的 spring-data。我有一个存储库 public interface DocumentRepository extends MongoRe
我在 Mongo 中的文档结构是这样的: db.user.find() { "_id" : ObjectId("560fa46930a8e74be720009a"),
我正在通过 MongoRepository 将 Spring Data 与 MongoDB 一起使用。 我想知道是否可以使用查询注释通过过滤器进行删除。我一直在寻找这里和谷歌,我找不到任何文档。 最佳
我正在使用: org.springframework.data.mongodb.repository.MongoRepository 我从一个空的数据库开始,例如用 _id = 1234 创建一个对象
我的 pojo public class PacketData implements Serializable { private static final long serialVersio
我正在尝试使用自己的查询来查询 mongo 存储库: @Repository public interface LogEntryRepository extends MongoRepository {
我是一名优秀的程序员,十分优秀!