Hi, @slava I got your point. But, i have a parent child relationship in a same collection. So, to fetch the child objects, i’m using lookup but it returns child objects in an array.
Result like this:
{
_id: 1,
name: "Parent product",
is_child: false,
is_parent: true,
children: [
{
_id: 1,
name: "Child 1",
is_child: true,
is_parent: false,
children : []
},
{
_id: 2,
name: "Child 2",
is_child: true,
is_parent: false,
children : []
}
]
}
This is my exact structure. Parent & child record should be in different objects.
Output like this:
{
_id: 1,
name: "Parent product",
is_child: false,
is_parent: true,
},
{
_id: 1,
name: "Child 1",
is_child: true,
is_parent: false,
children : []
},
{
_id: 2,
name: "Child 2",
is_child: true,
is_parent: false,
children : []
}
@slava So can you help me out to get the exact structure of output.