小编Seb*_*ian的帖子

额外的引号被添加到@Query

我有以下JSON结构:

{
  "communication": {
      "office": {
        "email": "test@example.com"
      },
      "private": {
        "email": "test2@example.com"
      },
  }
}
Run Code Online (Sandbox Code Playgroud)

我想基于类型(例如办公室或私人)动态查询电子邮件.当我使用以下命令时:

@Query(value = "{ 'communication.?0.email' : ?1 }")
Object findByEmail(String type, String email);
Run Code Online (Sandbox Code Playgroud)

'communication.?0.email'
Run Code Online (Sandbox Code Playgroud)

转换为

'communication."office".email'
Run Code Online (Sandbox Code Playgroud)

和mongo没有找到一个条目.如何在办公前后避免报价?

spring-data spring-data-mongodb

7
推荐指数
1
解决办法
425
查看次数

标签 统计

spring-data ×1

spring-data-mongodb ×1