这是我第一次在这里提问。如果我无法向您解释清楚,请原谅我。
这是简单的 SQL 查询
select groupId from retryBatches where campaignId = campaignId and groupId is not null;
如何在 spring data mongodb 中编写上述内容?
我已经这样做了,但是如何只获取groupId
Query query = new Query(where("campaignId").is(campaignId).and("groupId").ne(null));
谢谢
最佳答案
你必须使用所谓的投影。可以这样完成
Query query = new Query(where("campaignId").is(campaignId).and("groupId").ne(null));
query.fields().include("groupId");
关于spring - 如何在 spring data mongodb 查询中选择特定列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48111358/