I'm new to MongoDB so this might be a basic question but I am having trouble in how to approach it.
I want to find one document in my collection, like so:
db.collection("articles").find({curid:"1000143"}).asArray();
One of the fields returned is an array containing other document's 'curid' (a unique value):
HDP_Topics = ["1124516", "101388", "1031462", "1053284", "1077080", "1150760", "1092377", "1100194", "1103692", "1135134", "1134909", "1119820", "1000634", "1120316", "1000143"]
What I want to do is to find each of these other documents and append them onto the already existing find query results. I'm sure there must be a way without having make a new search for every element in the array.
(I'm using mongoDB Atlas's Stitch if that makes any difference)
If I understand the question correctly, you want to use the HDP_Topics field to trigger a new search. You can use a $graphLookup for this:
If you want to have more recursion level, change
maxDepth
. This search will put the resulting documents underotherDocs
.