Why Validated Method AND Collection2?

I’m following Meteor’s best practices of using mdg:validated-method and aldeed:collection2.

I’m just curious, why should I have both?

Methods are not necessarily for database operations, they can be used for many different tasks like calling api’s, chaining into other methods, sending emails, doing calculations etc. The “validated” aspect is to ensure that the parameters are valid and any parameter related error is a standardized validation error, not an obscure Match error.

Collection2 on the other hand is strictly database scoped but can also be used outside the context of a method, called within or from a method, or completely unrelated.

It is up to you to decide either one, or both to be the most suitable tool for any given task.

1 Like