Reputation: 13721
My application is publishing a 'memberPrice' field when it is not supposed to. In my publish.js file, I specified the memberPrice to not be published. Here is my server/publish.js:
Meteor.publish('cars', function() {
return Products.find({category: 'vehicle'}, {limit: 10}, {fields: {memberPrice: 0}});
});
My controller:
carsController = RouteController.extend({
waitOn: function () {
var sessionId = Session.get('sessionId');
console.log("Session: ", sessionId);
Meteor.subscribe('cars');
Meteor.subscribe('cartItems', sessionId);
},
action: function() {
this.render('Cars');
}
});
Here's my table using the aldeed:tabular package:
TabularTables = {};
Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);
TabularTables.Cars = new Tabular.Table({
name: "Cars",
collection: Products,
columns: [
{data: "productCode", title: "Product Code"},
{data: "brand", title: "Brand"},
{data: "productLineName", title: "Product Name"},
{data: "description", title: "Description"},
{data: "memberPrice", title: "Member Price"}
]
});
Does anyone know what's going on?
Thanks!
Upvotes: 0
Views: 101
Reputation: 8345
You're passing three arguments to Products.find
, but it only expects two. {limit: 10}, {fields: {memberPrice: 0}}
should be {limit: 10, fields: {memberPrice: 0}}
.
Upvotes: 2
Reputation: 11376
In the past i do publish like the one you have, but since i read this post from David Weldon page.
I change my publish to something like this.
Meteor.publish('cars', function() {
var selector = {category: 'vehicle'};
var options = {limit: 10,fields: {memberPrice: false}};
return Products.find(selector,options);
});
Based on the Publish function you have, the memberPrice option should be exclude here, try with this, here we are following the correct syntaxis of the Collection.find wich is collection.find([selector], [options])
and you have something like collection.find([selector],[selector],[options])
.
Upvotes: 1