使用@Query spring data mongorepository进行动态绑定

时间:2016-02-27 20:26:09

标签: mongodb spring-data mongorepository

从下面的json我想根据用户请求参数检索国家,类别等的数据。我该怎么做? 下面的代码片段我用于mongo存储库

@Query(value = "{ 'offeringInfo.offeringId' : ?0}", fields = "{'fields':1}")
Offering findOfferingByFields(String offeringId, String fields);

{ 
  "_id" : "PMRS774616-PICSD215", 
  "offeringInfo" : { 
    "service" : "HBOGO", 
    "mindOfferingId" : "PMRS774616", 
    "offeringType" : "FEATURE", 
    "offeringId" : "PMRS774616-PICSD215" 
  }, 
  "categories" : [ "Late Night Movies" ], 
  "country" : { 
    "name" : "US", 
    "isoCode" : "840", 
    "startDate" : "2015-09-09T06:00:00.000-04:00", 
    "endDate" : "2016-12-31T00:00:00.000-05:00" 
  }, 
  "photos" : [ ]
}

0 个答案:

没有答案