だから、私は Meteor プロジェクトに取り組んでいますが、このルートを適切に生成することはできません。
<template name="browseAll">
<h3>List of classes with books available!</h3>
<ul>
{{#each aggCount}}
<li><a href="{{ pathFor 'browse-class' }}">{{ _id }}</a> ({{ count }})</li>
{{/each}}
</ul>
</template>
反復処理されるデータは、MongoInternals を使用した集計の結果であり、次のようになります。
(server/methods.js の抜粋):
classCount: function() {
// Attempt aggregation of the books table to count by class, maybe.
var db = MongoInternals.defaultRemoteCollectionDriver().mongo.db;
var col = db.collection("books");
var aggregateSync = Meteor._wrapAsync(col.aggregate.bind(col));
var pipeline = [
{$group: {_id: "$class", count: {$sum: 1}}},
{$sort: {_id: 1}}
];
var theAnswer = aggregateSync(pipeline);
return theAnswer;
}
データは問題なく送信されているようで、集計からのサンプル データ (テンプレートに送信される) は次のようになります。
[ { _id: 'ADNR1234', count: 2 }, { _id: 'ARTH1234', count: 1 } ]
これが私が入手したテンプレート コードであり、これが動作するはずのルートです。
this.route('browse-class', {
path: '/browse/:_class',
data: function() {
var booksCursor = Books.find({"class": this.params._class},{sort:{"createdAt": 1}});
return {
theClass: this.params._class,
numBooks: booksCursor.count(),
books: booksCursor
};
}
});
わかりません。データは表示されています。私がやりたいことは、ヘルパーbrowse-class
の値をパラメーターとして受け取る (ルート)の URL を生成{{ _id }}
して、次のようなものを生成することです。
application.org/browse/CLSS