mongoose中的流查询stream query

mongoose中的流查询stream query,功能类似于php中的mysql_fetch_array,每次从集合中获取一条记录(文档)

1 var cursor = Person.find({ occupation: /host/ }).cursor();
2 cursor.on('data', function(doc) {
3   // Called once for every document
4 });
5 cursor.on('close', function() {
6   // Called when done
7 });
原文地址:https://www.cnblogs.com/toward-the-sun/p/6371103.html