我有两个集合,对于一些objects
和parents
:
Objects = new Meteor.Collection('objects');
Parents = new Meteor.Collection('parents');
对象包含一些字段并引用父对象,例如:
Objects.insert({ name: "o1", parent: "p1", f1: "val1", f2: "val2", f3: "val3" });
Objects.insert({ name: "o2", parent: "p2", f1: "val4", f2: "val5", f3: "val6" });
父母定义可以发送给客户端的字段,例如:
Parents.insert({ name: "p1", allowedFields: [ "name", "f1", "f2" ] });
Parents.insert({ name: "p2", allowedFields: [ "name", "f1", "f3" ] });
我想发布/订阅所有对象,但接收它们的非允许字段。
根据上面的示例,我期望客户端有以下内容:
{ name: "o1", f1: "val1", f2: "val2" });
{ name: "o2", f1: "val4", f3: "val6" });
我怎样才能有效地做到这一点?
语境:
- 流星
- 我通常会有 100
parents
和 1000objects
- 我事先不知道我会有多少个
parents
/ ,也不知道每个人会引用哪些允许的字段objects
parent