inProgress-team / react-native-meteor

Meteor Reactivity for your React Native application :)
MIT License
693 stars 210 forks source link

Transform on subscription #207

Closed JWDobken closed 7 years ago

JWDobken commented 7 years ago

A method I often use for client-side joins of two collections is transform. This is best explained with an example, where the collection Activities gets attributes from the collection libraryItems with the key libraryitem:

export default createContainer(() => {
  let activitiesSub = Meteor.subscribe('allActivities');
  let libraryItemsSub = Meteor.subscribe('allLibraryItems');
  var activities = Activities.find({}, {
      transform: function (doc) {
        doc.libraryitem = LibraryItems.findOne({
          _id: doc.libraryItemId
        });
        return doc;
      }
    }).fetch();
  return {
    activities: activities,
  }
}, App);

This works perfect for me in Meteor React, but the transform method does not work in react-native-meteor. What is the best alternative for client-side-joins here?