【发布时间】:2018-12-22 13:57:10
【问题描述】:
在 find ("-_id services.location") 的 mongoose 查询中,stringifying 的输出是:
[
{
"services":[
{
"location":[
17.4374614,
78.7482878
]
},
{
"location":[
17.4020637,
78.18400519324596
]
},
{
"location":[
17.56208737,
78.284005186526
]
},
{
"location":[
17.5620637,
78.3240051999554
]
}
]
}
]
有什么方法可以让我从我得到的输出中访问每个单独的位置值,例如(17.4374614、78.7482878、17.4020637....)。
我的架构如下:-
var serviceSchema = new mongoose.Schema({
location:[{type: Number}]
})
【问题讨论】:
-
在下面查看我的答案,也试试我分享的链接。
标签: arrays node.js mongodb mongoose aggregation-framework