如何在一个反应​​表中使用两个集合?流星Js

时间:2016-04-28 11:49:06

标签: meteor meteor-blaze

我想使用meteorjs在一个反应​​表中使用两个集合。我有两个集合,我想在单个表中合并这些集合。我没有线索请帮忙!!!

2 个答案:

答案 0 :(得分:1)

查看reywood:publish-composite包裹。它允许您发布反应性连接。

https://github.com/englue/meteor-publish-composite

答案 1 :(得分:0)

使用反应表时,您可以使用dynamic column,它允许您为列定义功能。然后,您可以使用此函数在另一个集合中查找数据。

示例:

{ fieldId: 'someOtherThing', // needs to be unique in your table
  key: 'otherId', // this should be the _id of the other collection you want to "join"
  label: 'Some Label',
  fn: function(_id){
    const otherObject = OtherCollection.findOne(_id);
    if ( otherObject ) return otherObject.someKey;
  }
},