mongodb异步驱动程序-它如何工作

时间:2018-09-21 15:21:05

标签: mongodb mongodb-query mongodb-java

有人知道我通过查询时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也会首先获取查询返回的所有数据,然后将其流式传输到文件 或

它将在返回记录时按流方式发送吗?

0 个答案:

没有答案