R
R
riddlr2018-10-16 18:31:44
MongoDB
riddlr, 2018-10-16 18:31:44

How to make a recursive populace?

There is a scheme comment, with a field repliesin which there are others comment, which can also have replies, and so on ad infinitum.

Post.findOne({slug}).populate({path: 'comments', populate: {path: 'replies', populate: {path: 'replies'}}}).exec()

Such a code populates only to the specified nesting level, but what if these levels are not 3 like here, but 5-10? How to do automatic recursive populace?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question