【发布时间】:2014-09-05 22:36:16
【问题描述】:
我正在建立我的管理区域。我认为让多个管理员用户每个都可以访问相同的数据会很有用。我正在使用这个roles package。
我正在使用 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)
有什么想法吗?
【问题讨论】:
标签: javascript meteor