mongo输出树结构,但是输出了object对象

新手上路,请多包涵

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] ] }
]

这是我的数据储存结构
image.png

阅读 1.7k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题