流星发布领域问题

Meteor publishing field issue

我的应用程序不应该发布 'memberPrice' 字段。在我的 publish.js 文件中,我指定不发布 memberPrice。这是我的 server/publish.js:

Meteor.publish('cars', function() {
return Products.find({category: 'vehicle'}, {limit: 10}, {fields: {memberPrice: 0}});
});

我的控制器:

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

});

这是我的 table 使用 aldeed:tabular 包:

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"}

 ]
});

有人知道这是怎么回事吗?

谢谢!

您将三个参数传递给 Products.find,但它只需要两个。 {limit: 10}, {fields: {memberPrice: 0}} 应该是 {limit: 10, fields: {memberPrice: 0}}

过去我确实像您那样发布,但自从我从 David Weldon 页面阅读此 post。

我将我的发布更改为这样的内容。

Meteor.publish('cars', function() {
  var selector = {category: 'vehicle'};
  var options = {limit: 10,fields: {memberPrice: false}};
  return Products.find(selector,options);
});

根据您拥有的 Publish 功能,此处应排除 memberPrice 选项,尝试使用此选项,此处我们遵循 Collection.find 的正确语法,即 collection.find([selector], [options]),您有一些东西像 collection.find([selector],[selector],[options]).