Autoform server side pre insert processing


#1

Using AutoForms, hooks are a great way to add client-side default or custom fields before inserting/updating the collection.

For the life of me, I can’t work out how to do this on the server side instead.
AutoForms provide the method and method-update type for simple schemas, however, i’ve been using update-pushArray for adding new messages to a thread but I’d like to be able to add default fields to the new message on the server side.


#2

You have two very easy options:

and if you like the latter, here’s a great video MeteorCasts ep2 - dburles:collection-helpers and a good article https://www.discovermeteor.com/blog/a-look-at-meteor-collection-hooks/

Of course you can always use http://docs.meteor.com/#/full/meteor_methods for more control