发布于 2015-09-14 15:00:51 | 110 次阅读 | 评论: 0 | 来源: 网络整理
The forEach() method iterates the cursor to apply a JavaScript <function> to each document from the cursor.
The forEach() method accepts the following argument:
参数: |
|
---|
The following example invokes the forEach() method on the cursor returned by find() to print the name of each user in the collection:
db.users.find().forEach( function(myDoc) { print( "user: " + myDoc.name ); } );
也可以参考
cursor.map() for similar functionality.