Hey guys,
I’m currently using react-native-meteor within my RN application and try to handle some relational data. For example, I’m having a user_files collection and try to add some functions via transform method:
function transformDoc(doc) {
doc.fileDoc = Meteor.collection('files').findOne({_id:doc.fileId});
return doc;
}
const UserFile = Meteor.collection('user_files',{transform:transformDoc});
The problem with this construction is, that Meteor can’t guarantee that all data is available when calling transformDoc
. So sometimes the data of the files
collection isn’t available while transforming the doc. In this case we don’t get a fileDoc
, which causes errors in our RN application. I publish all data via publishComposite.
What would be the best way to handle such relations? I know that I could try to get the file document within a Meteor container and pass it to the React component, but that would be a little bit ugly.