skip to Main Content

Mongodb – Given an id of a document with recursive field `children`, find all documents that reference the document or any of its children

I have a collection of product folders productfolders and a collection of products products. const ProductFolderSchema = new Schema( { folderName: { type: String, required: true }, parent: { type: Schema.Types.ObjectId, ref: 'ProductFolder' }, children: [{ type: Schema.Types.ObjectId, ref: 'ProductFolder'…

VIEW QUESTION
Back To Top
Search