mongoose我查询出来却是object类型,我该怎么把他展开
Sort.aggregate().graphLookup({
from: "Sort",
startWith: "$children",
connectFromField: "children",
connectToField: "_id",
as: "children"
}).unwind("children").group({
_id: "$_id",
children: { $push: "$children" }
}).then(function (res) {
console.log(res);
})
这是输出的结果,我想要吧object展开就行
[
{
_id: 60ed38f32c4f7a6534d2a113,
children: [ [Object], [Object], [Object], [Object] ]
},
{ _id: 60ed39112c4f7a6534d2a117, children: [ [Object], [Object] ] }
]
这是我的数据储存结构
有多种方法,
util.inspect
,JSON.stringify
都行,具体看这里:https://stackoverflow.com/que...