The documentation states that you can specify a transform function on the Mongo.Collection and/or with on a Collection.find()
It does not specify where the transform runs, client or server side.
I have been fiddling with this, thinking I can attach a transform to the Collection.find inside a publish, which does not seem to work.
Can someone confirm how and where exactly a transform can occur, and if I just overlooked something in the docs? I could not find any mention that it would not work inside a publish.
… Documents will be passed through this function before being returned from fetch or findOne, and before being passed to callbacks of observe, map, forEach, allow, and deny. Transforms are not applied for the callbacks of observeChanges or to cursors returned from publish functions.
The point being that the cursor returned from a publication will not have the transform applied. Only when a document is fetched (either explicitly with fetch or findOne, or implicitly - as with Blaze), will the transform be executed.
So, it will run on client or server, depending on how you reference the documents in your collection.
FWIW, I’m using reywood:publish-composite and it allows transforms within the publish functions. And they happen to work. There may be perforamance implications though. And then, there’s this comment from the author himself, elaborating on the topic.
I think this thread should be closed, because it was a PEBCAK on my behalf, since I didn’t read the documentation right. And I started the other thread as well …