【发布时间】:2016-04-27 12:04:34
【问题描述】:
MongoDB 3.0.6 版
所以我有这个查询,我想在其中执行一些小于和大于操作。另外,我想执行一个or 操作,但我无法弄清楚java 中的语法。以下是我目前所拥有的:
FindIterable<Document> iterable3 = db.getCollection(collectionName).find(
new Document()
.append("timestamp", new Document()
.append("$gte", startTime)
.append("$lte", endTime))
.append("hourOfDay", new Document()
.append("$gte", minHourOfDay)
.append("$lte", maxHourOfDay))
.append("dayOfWeek", new Document()
.append("$or", new Document("2","4")))
);
我想要的查询还检查dayOfWeek 参数是否等于2 或4。
【问题讨论】: