Hi there-
I am attempting to update an attribute of an object located within an array of a collection, but I seem to be having a little trouble.
There is a collection of apps, and within the apps, there is an array of reviews. I am trying to update a “delete” boolean attribute within the review object.
Unfortunately, it looks like I have an error somewhere in my Apps.update query. Anyone able to please help point me in the right direction?
Thanks!
Apps.update(doc._id, { 'reviews._id': reviewId { '$set' { delete: true } } } );
UPDATE
Perhaps I am on the right track with the code below, but I am getting an error "untrusted code may only update documents by ID. This confuses me as I am updating both the Apps document and reviews object by ID.
Apps.update({ '_id': doc._id, 'reviews': reviewId }), { '$set': { 'deleted': true }};
UPDATE #2
To anyone following my little journey here, I think I’ve found the better way to access which review I am trying to edit with @index, instead of doing an update for the app by id, then trying to grab the review by reviewId.
I can successfully grab the index of each of my reviews within the app object, however, any data associated with the specific review is gone whenever I do it. It might be because I am incorrectly using @index, so here’s what I have:
{{#each reviews}}
<br> {{#if Template.subscriptionsReady}} {{> Review index=@index}} {{else}}
<p>Loading...</p>
{{/if}}
{{/each}}
When index=@index is removed from the Review template handlebars, the data is available. With index=@index within the handlebars, the data is simply missing from the template when I call attributes, example is {{content}} of the review shows when @index is not there, but with it, it’s simply blank.
Would anyone be able to help me position this the correct way?
Thank you all once again.