嵌入式文档的Spacebars语法(Spacebars syntax for embedded documents)

系统教程 行业动态 更新时间:2024-06-14 16:57:18
嵌入式文档的Spacebars语法(Spacebars syntax for embedded documents)

我对公司的财务报表信息有以下架构:

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);

我试图引用LTM,FY + 1和FY + 2收入数据,使用空格键显示在表格中。 我的收藏中已经有以下内容,并通过控制台测试了收入和EBITDA数据都是在LTM下捕获的。

Companies.insert({ name: "Example", sector: "Industrial", status: "Public", time: { period: "LTM", financials: { revenue: "200", ebitda: "100" } } });

我原以为{{period(“LTM”)。revenue}}会起作用,但已经尝试过几十种变化,无法将数字显示在表格中。 谢谢。

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.

最满意答案

您可能需要查看Spacebars自述文件 ,因为我不相信{{period("LTM").revenue}}是一个有效的空格键标签。 通过空格将函数名称与其参数分开来调用函数,如下所示: {{functionName arg1 arg2}} 。

为了得到你想要的东西,你需要先得到感兴趣的公司,可能还有一个帮助Companies.findOne({period: "LTM"})返回Companies.findOne({period: "LTM"}) 。

将公司作为数据上下文后,您需要使用{{time.financials.revenue}}和{{time.financials.ebitda}}来获取收入和EBITDA值。 您编写架构的方式,每个公司条目只能有一个收入和EBITDA值,并且它们存储在time.financials对象中。

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.

更多推荐

本文发布于:2023-04-12 20:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/e054816405e5ec27917d3e128cd24ab8.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:嵌入式   语法   文档   documents   Spacebars

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!