发布于 2015-09-14 15:00:51 | 103 次阅读 | 评论: 0 | 来源: 网络整理

cursor.forEach(<function>)

The forEach() method iterates the cursor to apply a JavaScript <function> to each document from the cursor.

The forEach() method accepts the following argument:

参数:
  • <function> – JavaScript function to apply to each document from the cursor. The <function> signature includes a single argument that is passed the current document to process.

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.

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务