I am trying to follow aldeed’s example here for using reywood:publish_composite. I can see all of the building names in my table, but I can’t see the region names. Can anyone see what I’m doing wrong here?
{{> tabular table=TabularTables.Buildings class="table table-striped"}}
an example of a Building (in the Buildings collection):
{
_id: 'XDkCcn9RrSx7YjKha',
name: 'My Building #1',
region_id: 'RfcrxrD7W7MnQvqiM'
}
an example of a Region (in the Regions collection):
{
_id: 'RfcrxrD7W7MnQvqiM',
name: 'Southern California'
}
in common/helpers.js
Buildings.helpers({
region_name: function() {
var region = Regions.findOne({_id: this.region_id});
return region && region.name;
}
});
in common/tables.js
TabularTables = {};
TabularTables.Buildings = new Tabular.Table({
name: "Buildings",
collection: Buildings,
pub: 'tabularBuildings',
allow: function() {
return true;
},
order: [[0, "asc"]],
columns: [
{data: "name", title: "Building Name"},
{data: 'region_name()', title: "Region"}
]
});
In server/publish.js
Meteor.publishComposite("tabularBuildings", function(tableName, ids, fields) {
check(tableName, String);
check(ids, Array);
check(fields, Match.Optional(Object));
this.unblock();
return {
find: function() {
this.unblock()
return Buildings.find({_id: {$in: ids}}, {fields: fields});
},
children: [
{
find: function(building) {
this.unblock();
return Regions.find({_id: building.region_id}, {limit: 1, fields: {name: 1}, sort: {_id: 1}});
}
}]
}
});
I’m also using meteorhacks:flow-router, meteorhacks:flow-layout, arillo:flow-router-helpers