Files
meteor/docs/rules/methods.md
Dominik Ferber 1a1f29e477 feat(methods): Add rules for methods
This also refactors common functionality with pubsub into utility files.

#3
2015-10-18 19:27:42 +02:00

1.1 KiB

Core API for methods (methods)

Prevent misusage of methods.

Rule Details

This rule aims to prevent errors when using methods.

The following patterns are considered warnings:


Meteor.methods()          // missing argument


Meteor.call()             // missing argument


Meteor.apply()            // missing argument


new Meteor.Error()        // missing argument


Meteor.methods({
  foo: function () {
    this.userId = true    // can not be changed
    this.isSimulation++   // can not be changed
    this.connection++     // update not allowed

    this.unblock = true   // can not be changed; allowed on server only
    this.setUserId()      // missing argument; allowed on server only
  }
})

The following patterns are not warnings:


Meteor.call('foo')


Meteor.apply('foo', [])


Meteor.methods({
  foo: function () {
    return Bar.find({ _id: this.userId })
  }
})

Limitations

  • Does not verify usage of DDPRateLimiter.

Further Reading