我有一个名为Mongodb of Meteor的文章集,文章集有一个名为References的嵌入式文档,它本身有一个名为Ref的嵌入式数组文档 . 该文件如下:
{ "article":
{
"Section":
{
"Section-Title":
[{"key11":"value11"},"value12"],
"SSD":["value","value"]
}
"References":
{
"Ref": [
{ "key21":"value21",
"key22":"value22",
"key23":value23,
"key24":"value24"
},
{}
]
}
}
}
我想显示所有文章的值24,我首先尝试确保我可以使用key24 =“aspecificrvalue”显示文章 .
WHat I have tried:
使用meteor mongodb命令行上的命令行,我使用以下命令得到了正确的文章,其中ref .key24是aspecificvalue:
db.articles.find({"article.References.Ref.key24":"aspecificvalue"})
然后我尝试实现上面的查询,但是在meteor客户端的表单上得到结果:因为asmy meteor应用程序有3个文件:-article.html,-articlesTemplate.html,-and articles.js
以下是每个文件的内容,
- articles.html
<head>
<title>Athena Project</title>
</head>
<body>
<h1>Welcome to Athena project</h1>
{{>articlesTemplate}}
</body>
-articlestemplate.html 文件
<template name="articlesTemplate">
<ul>
<h3>List of available articles</h3>
{{#each article}}
{{>articlesInfo}}
{{else}}
there is nothing in articles database
{{/each}}
</ul>
</template>
<template name="articlesInfo">
<li>
<b>Key24 is:</b>{{article.References.Ref.Key24}}
</li>
</template>
- articles.Js 文件:
Articles = new Meteor.Collection("articles");
if (Meteor.isClient) {
Template.articlesTemplate.helpers({
articlesTemplate: function() {
return Articles.find({'article.References.Ref.key24':'aspecificvalue'});
}
});
}
if (Meteor.isServer) {
Meteor.startup(function ()
{
});
}
Result of my try:
在我的流星形式这个代码显示"there is nothing in articles database"好像它没有在我的数据库中读取任何内容,我仍然是meteor的新手 Please help with how to display the content of an embedded document in a collection using meteor code
谢谢你的帮助 .