I am in the process of creating a publication that will provide me with a series of documents from the collection. The relationship between these documents can be seen below:
{
"_id" : "peRuJcPMDzZgTvWSX",
"author" : "author",
"type" : "article",
"parent" : "mnfTFfZ7Fqcu6ZJ7T",
"ancestors" : [ "hbSycmNNvmdqvpchX", "mnfTFfZ7Fqcu6ZJ7T" ]
}
{
"_id" : "mnfTFfZ7Fqcu6ZJ7T",
"article" : "article",
"parent" : "hbSycmNNvmdqvpchX",
"ancestors" : [ "hbSycmNNvmdqvpchX" ]
}
{
"_id" : "hbSycmNNvmdqvpchX",
"title" : "title",
"ancestors" : [ ]
}
My objective is to retrieve all ancestors in the publication based on the ID of the first document.
Meteor.publish('list', function(id) {
check(id, String);
return Collection.find({}); // this returns ALL documents (wrong)
return Collection.find({ _id: id }) // this only fetches the first document (main) (wrong)
// I NEED: The main document and all its ancestors
});