我正在使用collection.find执行Mongodb node.js,如何只将没有列名的数据返回到数组中。
var cursor = collection.find( { title: title }, { title: 1, _id: 0 });
cursor.sort( { title: 1 });
cursor.toArray(function (err, all_documents) { .... });{“标题”:“MongoDB概述”}{“标题”:“NoSQL概述”}{“标题”:“教程点概述”}
发布于 2015-12-08 15:25:49
collection.find(...).toArray().map( function(u) { return u.title; } )或
var result = []
collection.find().forEach(function(u) { result.push(u.title) })https://stackoverflow.com/questions/34159247
复制相似问题