I have the following schema for a company's financial statement information:
FinancialsSchema = new SimpleSchema({
revenue: {
type: Number,
label: "Revenue",
min: 0,
optional: true
}
});
TimeSchema = new SimpleSchema({
period: {
type: String,
label: "Period",
optional: true
},
financials: {
type: FinancialsSchema,
optional: true
}
});
CompanySchema = new SimpleSchema({
name: {
type: String,
label: "Company Name"
},
time: {
type: TimeSchema,
optional: true
}
});
Companies.attachSchema(CompanySchema);
I am trying to reference the LTM, FY+1 and FY+2 revenue figures using spacebars to display in a table. I already have the following in my collection and tested through the console that the revenue and EBITDA numbers have both been captured under LTM.
Companies.insert({
name: "Example",
sector: "Industrial",
status: "Public",
time: {
period: "LTM",
financials: {
revenue: "200",
ebitda: "100"
}
}
});
I would have thought {{period("LTM").revenue}} would work but have tried dozens of variations and can't get the figures to appear in the table. Thanks.
You might want to review the Spacebars Readme, because I don't believe {{period("LTM").revenue}}
is a valid spacebars tag. Functions are called by separating the function name from its arguments by a space, like so: {{functionName arg1 arg2}}
.
To get what you're after, you'll need to first get the copany of interest, probably with a helper that returns Companies.findOne({period: "LTM"})
.
Once you have the Company of interest as the data context, you'll need to use {{time.financials.revenue}}
and {{time.financials.ebitda}}
to get the revenue and EBITDA values. The way you've written your schema, each company entry can only have one revenue and EBITDA value, and they are stored in the time.financials object.