Meteor : Iterate through array of Objects inside an Object

I'm currently trying to iterate through an array of Objects inside an Object. I have my Collection "Proposals", and this is the corresponding Schema :

Schemas.ProposalsSchema = new SimpleSchema({
  'content': {
    type: String,
    max: 140
  },
  'parties': {
    type: [Object],
    autoform : {
      type: "select-multiple"
    }
  },
  'parties.$._id': {
    type: Object,
    optional: true
  },
  'parties.$._id._str': {
    type: String
  },
  'parties.$.name': {
    type: String
  }
});

I would like to iterate through the array of parties inside one of my template. I tried this :

{{#each proposals}}
    <p>{{content}}</p>
    <p>{{#each parties}} {{this.name}} {{/each}}</p>
{{/each}}

The content is displayed, but not the name of the different parties. Here's my template helper :

Template.proposalsIndex.helpers({
  proposals: () => Proposals.find().fetch()
});

Do you know what do i do wrong?

Thank you in advance.

Answers


The code you posted looks ok.

Things you need to check are:

  1. Is the "parties" field populated in a database? (you can run Proposals.find().fetch() in a meteor shell to check it).

    If not, find out why it is not populated.

  2. Is the "parties" field published to client? (you can run Proposals.find().fetch() in a browser console and see the results).

    If not, check your publication.


Need Your Help

RDLC item width is dynamic and causing extra pages to be generated (image included)?

reporting rdlc reporting-services

I'm trying to format an RDLC report file in Visual Studio 2008 and I am having a formatting issue. I have a list at the bottom that contains a matrix that expands horizontally to the right. That pi...

Windows Azure iOS Authentication

iphone windows azure azure-storage

Hi Anyone help me out in this issues it would be very appreciated , and it would be better myself , please review my task.