【发布时间】:2015-12-29 08:34:06
【问题描述】:
使用 Java。我有两个 .find() 查询,我想合并它们并获得一个包含两个查询结果的文档。我已经设法像这样单独创建它们。请注意,查询位于两个不同的顶级字段上。下面的最后一条语句是对同一字段的两个条件的查询。
FindIterable<Document> iterable = db.getCollection("1dag").find(new Document("id", "10"));
和
FindIterable<Document> iterable2 = db.getCollection("1dag").find(
new Document().append("timestamp", new Document()
.append("$gte",startTime)
.append("$lte",endTime)));
我找不到任何关于此的文档。 这是我应该使用“$and”或“$where”语句的地方吗?
编辑是这样做的吗?
FindIterable<Document> iterable7 = db.getCollection("1dag").find(
new Document()
.append("timestamp", new Document()
.append("$gte", startTime)
.append("$lte", endTime))
.append("id", new Document()
.append("$eq", 10)));
【问题讨论】: