cursor.map()

On this page本页内容

cursor.map(function)

mongo Shell Method

This page documents the mongo shell method, and does not refer to the MongoDB Node.js driver (or any other driver) method. 本页记录了mongo shell方法,未提及MongoDB Node.js驱动程序(或任何其他驱动程序)方法。For corresponding MongoDB driver API, refer to your specific MongoDB driver documentation instead.有关相应的MongoDB驱动程序API,请参阅特定的MongoDB驱动程序文档。

Applies function to each document visited by the cursor and collects the return values from successive application into an array.function应用于游标访问的每个文档,并将后续应用程序的返回值收集到一个数组中。

The cursor.map() method has the following parameter:cursor.map()方法具有以下参数:

Parameter参数Type类型Description描述
function function函数 A function to apply to each document visited by the cursor.应用于游标访问的每个文档的函数。

Example示例

db.users.find().map( function(u) { return u.name; } );

See also参阅

cursor.forEach() for similar functionality.用于类似的功能。