[SOLVED] Confusion over Client-Side Methods and Data Access

Let’s say I’m triggering a method from the browser which requires data from a collection which I’m not currently subscribed to. Do I need to wrap the method contents in a isSimulation check? What’s the best way to force server-side execution of a method when I don’t want to subscribe the needed documents?

Just put the method in a server directory and it’ll only be executed on the server.

If you don’t need optimistic UI (and if you’re not subscribed, then I assume you don’t), just ensure the method only executes on the server.

If you’re going old-school and writing your own Meteor.methods and Meteor.calls, then put the method in server-only code.

If you’re using validated-method, then you will need to to ensure the client doesn’t execute the method as well. A !isSimulation check inside the run function would be work as you suggest.

Thanks, guys. I’m using validated-method and importing the methods into React components. That’s what led to the confusion.

1 Like