Where should Meteor.methods() be defined?

后端 未结 4 701
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-13 15:31

http://docs.meteor.com/#meteor_methods

I have tried it in publish.js in my server folder.

I am successfully calling Meteor.apply and attempting the server ca

4条回答
  •  一整个雨季
    2020-12-13 16:14

    I hope some will find use of this addition, and this doesn't cloud the issue that methods are primarily intended to run on the server as debergalis has explained.

    Using Meteor.methods() on the client is useful too. (look for "stub" in the Meteor.call() section too...) This allows the client to (synchronously) simulate the expected effect of the server call. As mentioned in the docs:

    You use methods all the time, because the database mutators (insert, update, remove) are implemented as methods. (...)

    A separate section explaining use of stubs on the client might ease the understanding of methods calls on the server.

提交回复
热议问题