在 mongodb 中应用查找操作后..我得到以下文档列表..
After applying the find operation in mongodb.. i get the following list of documents..
db.users.find(....)
我明白了:
{ "text" : "Hey" }
{ "text" : "Hi" }
{ "text" : "Hello" }
{ "text" : "yes" }
如何转换成
["Hey","Hi","Hello","yes"].
我试过了
db.users.find(...).map( function(u) { return "u.text"; } )
但它给出了错误!
不确定你的语言实现是什么,但基本概念是:
Not sure what you language implementation is but the basic concept is:
var result = []
db.users.find().forEach(function(u) { result.push(u.text) })
而result的返回值为:
["Hey","Hi","Hello","yes"]
这篇关于如何在mongodb中只返回一个字段的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
检查一个多边形点是否在传单中的另一个内部Check if a polygon point is inside another in leaflet(检查一个多边形点是否在传单中的另一个内部)
更改传单标记群集图标颜色,继承其余默认 CSSChanging leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改传单标记群集图标颜色,继承其余默认
触发点击传单标记Trigger click on leaflet marker(触发点击传单标记)
如何更改 LeafletJS 中的默认加载磁贴颜色?How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默认加载磁贴颜色?)
将 Leaflet 图层控件添加到侧边栏Adding Leaflet layer control to sidebar(将 Leaflet 图层控件添加到侧边栏)
Leaflet - 在弹出窗口中获取标记的纬度和经度Leaflet - get latitude and longitude of a marker inside a pop-up(Leaflet - 在弹出窗口中获取标记的纬度和经度)