流星(0.9.0.1):使用助手与autoform更新多个用户的记录
问题描述:
我正在建立我的管理区域的过程。我认为让多个管理员用户都可以访问相同的数据会很有用。我正在使用这个roles package。流星(0.9.0.1):使用助手与autoform更新多个用户的记录
我使用自动窗体生成为“AdminA”登录的,所以当表单,该用户在表单中输入的值,并将其提交,则记录下AdminA的账户存储。 AdminB然后登录,但在窗体上看不到该值,因为该用户无权访问AdminA的帐户。我需要一种告诉autoform更新一条记录的方法。
下面的代码是我想要实现的。任何人都可以建议我需要做些什么才能使这个工作?我看过autoform文档,但我不完全确定。
的形式输入框看起来有点像这样渲染时:
<input type="text" name="VehiclePrice" value="10000" />
<input type="hidden" name="_id" value="LEXANiNZtunFPfBea">
模板:
<template name="VehiclePrice">
{{#if submitted}}
{{> quickForm collection="VehiclePrice" omitFields="createdBy" doc=editingDoc id="VehiclePrice" type="update"}}
{{else}}
{{> quickForm collection="VehiclePrice" omitFields="createdBy" id="VehiclePrice" type="insert"}}
{{/if}}
</template>
助手:
Template.VehiclePrice.helpers({
VehiclePrices: function() {
return VehiclePrice.find().map(function (c) {
return {price: c.price, _id: c._id};
});
}
});
的关系将是很多管理员用户一条记录(*:1)
任何想法?
答
通过发布车辆收集,你可以编程,确定谁有权访问数据,什么数据集出版。看看Meteor发布文档(http://docs.meteor.com/#meteor_publish)。
设置您的收藏后,你可以决定哪些数据集获得通过发布命令的东西等公布:
Meteor.publish("vehicleInfo", function() { if (this.role == "admin") return Vehicle.find(); else return Vehicle.find({some subset of the data, or none at all (false)}); });
答
事实证明,这是我的一个助手的问题。这是限制用户的数据,我赞赏并且它工作正常。
我已经更新的问题,我不认为我是不够清楚。 – user1532669 2014-09-03 23:55:28