Harjeet Singh
Harjeet Singh

Reputation: 65

How can I use two collections in one reactive table? Meteor Js

I wanna use two collections in one reactive table using meteorjs. I have two collections and I want to merge these collection in single table. I have no clues please help!!!

Upvotes: 0

Views: 335

Answers (2)

Michel Floyd
Michel Floyd

Reputation: 20227

When using reactive-table you can use a dynamic column which allows you to define a function for a column. You can then use this function to lookup data in another collection.

Example:

{ 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;
  }
},

Upvotes: 0

aedm
aedm

Reputation: 6564

Take a look on reywood:publish-composite package. It allows you to publish reactive joins.

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

Upvotes: 1

Related Questions