1
MongoDB版本3.0.6MongoDB:查詢或語句
所以我有這個查詢,我想執行一些小於和大於操作。此外,我想要執行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
。
ha看看這個http://stackoverflow.com/questions/10620771/how-can-i-build-an-or-query-for-mongodb-using-the-java-driver – piyushj