'Mongoose Unilevel Query

How can I do unilevel query with mongoose.

Example collection :

ID NAME PARENT ID
1 Alex 0
2 Michael 1
3 George 2
4 Yuri 1

Example output :

[{ id:1, name:Alex, parentId:0},{ id:2, Michael, parentId:1},{ id:3, name:George, parentId:2},{ id:4, name:Yuri, parentId:1}]

Thanks for helps.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source