码上敲享录 > mongoDB常见问题解答 > MongoRepository的@Query多条件查询

MongoRepository的@Query多条件查询

上一章章节目录下一章 2019-12-19已有6769人阅读 评论(0)

MongoRepository的@Query多条件查询


解决方法:

?0标识匹配方法的第一个参数,?1第二个参数,{ '_id' : 1}表示结果只返回_id这个属性,其他属性在对象中都是空的。

@Component

public interface QuestionDao extends MongoRepository<Question,String> {

   @Query(value="{'$and': [{ 'surveyId':?0},{'title':?1}]}",fields="{ '_id' : 1}")

   public List<Question> getQuestionListBySurveyIdAndOptLimit(Long surveyId,String title);

}


向大家推荐《Activiti工作流实战教程》:https://xiaozhuanlan.com/activiti
0

有建议,请留言!

  • *您的姓名:

  • *所在城市:

  • *您的联系电话:

    *您的QQ:

  • 咨询问题:

  • 提 交