Newbie question: returning Collection.find fields


#1

I have an FS collection. In this FS collection I have uploaded some files. I have attached these files to a list. The list has an ID and that ID is passed and saved to the metadata of FS File.

In mongoDB I see this structure.
_id
original
metadata
–> creatorId
–> createdAt
–> listId

I want to return to the uploads page only items that are relevant to the list.

So I try and return the collection using this.

Template.uploadsPage.helpers({
  uploads:function(){
    var currentList = this._id;
    return Uploads.find({metadata: [{listId: currentList}]}, {sort: {createdAt: -1}})
  }
})

Can somebody offer some guidance?


#2

you need Uploads.find(whatever).fetch() before you can use {{ #each uploads }}
And I think, not sure that you can use selector something like: { metadata.$.listId: currentlist }


#3

Thank you!

This worked.

return Uploads.find({‘metadata.listId’: currentList})