我正在尝试查询具有以下格式的文档的集合:
{
"_id": "592be59e31c4fb0d04dba4f8",
"CaseID": "XRTYET",
"curdate": "2017-05-29",
....
"env": "Mumbai",
"description": null,
....
"release": "0.0.1",
...
}
我尝试使用以下方法搜索集合中是否存在以下测试字段:
this.mongoCollection.find(and(eq("CaseID", val.getCaseID()), eq("curDate", val.getCurDate()), eq("environment", val.getRelease())))
.projection(new Document("CaseID", 1).append("CurDate", 1).append("environment", 1).append("_id", 0))
.forEach(printBlock);
我也尝试计算它,但输出为0.计数的语法是: -
long count = this.mongoCollection.count(and(eq("CaseID", val.getCaseID()),
eq("curDate", val.getCurDate()),
eq("environment", val.getRelease())));
即使文档存在,计数也为0,我无法根据id或CaseID,curDate和环境查询状态文档。