According to this video, meteor methods should be defined in the models.js file that is available on the client and the server.
If methods are supposed to be secure procedures that the client invokes on the server, why are they defined in the models.js file? Clients call methods with Meteor.call, so doesn't it make sense to define our methods on the server, not in models.js?
You don't have to put methods in a "model.js" file, you can put them anywhere, they just happened to name the file model.js in the video.
Meteor.methods
is an "Anywhere" method, which means that it can exist on both the server and the client. If you look at the docs, you'll see the difference explained:
Calling methods on the server defines functions that can be called remotely by clients.
[...]
Calling methods on the client defines stub functions associated with server methods of the same name.
In the video they're showing you a demo of how methods and other features of Meteor work, so they weren't concerned with specifically placing the methods in the server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With