有人知道我通过查询时MongoDB async driver
的工作原理吗?
mongoCollection.aggregate(bsonList).allowDiskUse(allowDiskUse).forEach(new Block<Document>() {
public void apply(Document document) {
try {
Files.write(Paths.get("test.json").toAbsolutePath(), document.toJson().getBytes(), StandardOpenOption.APPEND);
} catch (Exception exception) {
logger.error("Exception while Streaming to the file" + exception.getMessage(), exception);
}
}
}
我正在使用上面的代码将数据流式传输到文件。
我正在bsonList中传递我的查询({'$match':{'_id':'10001'}})
。
MongoDB也会首先获取查询返回的所有数据,然后将其流式传输到文件 或
它将在返回记录时按流方式发送吗?