On calling a Meteor method with Meteor.bindEnvironment to create a new Fiber, the data context is no longer available. The insert ID returns undefined.
Meteor.call('saveData', data, function(error, result){
let returnValue = Collection.findOne({'data': result }).buffer;
}
});
Meteor.methods({
'saveData': function(data) {
let doc = new PDFDocument();
doc.image(data, 0, 0);
doc.pipe(concat(Meteor.bindEnvironment(
function(buffer) {
let newID = Collection.insert({
'data': buffer,
});
}
)));
}
doc.end();
return newID;
});
I have attempted using Meteor.bindAsync because I thought I would have a new Fiber and the original data context, but I still get the error that Meteor must run within a Fiber. How can I bind newID to the original data context to pass it back once the insert has finished?