I want to add and return the calculated field from the Meteor.publish server, which is not actually saved in MongoDB. Is it possible? Something like where I will format some markdown:
Meteor.publish('recentEdits', function(pageId) { var edits, formattedContent; edits = WikiEdits.find({pageId: pageId}, {sort: {ts: -1}, limit: RECENT_EDIT_LIMIT}); edits.forEach(function(edit) { formattedContent = marked(edit.content); edit.formattedContent = formattedContent; }); return edits; });
It should seem to the client that the formattedContent field appeared like any other, but this is not really in MongoDB. Is this possible, and if so, what is the best way? Even if I have to keep formattedContent, I would still like to know how to do this.
I tried using the transform option in Meteor.Collection and only worked on the client, but I want this to happen from the server.
source share