Search code examples
meteormeteor-accountsddp

Which methods are available via DDP in Meteor?


When communicating with a Meteor server over DDP, I've found that the following methods are available:

  • If you have defined a method myMethod in Meteor.methods({ ... })
    • {"msg":"method","method":"myMethod","params":[],"id":"1"}
  • If you have enabled the accounts-password package
    • {"msg":"method","method":"createUser","params":[{ ... }],"id":"1"}
    • {"msg":"method","method":"login","params":[{ ... }],"id":"1"}
  • If there exists a collection called mycoll on the server
    • {"msg":"method","method":"/mycoll/insert","params":[{"_id":"some-doc"}],"id":"1"}
    • {"msg":"method","method":"/mycoll/update","params":[{ ... }],"id":"1"}
    • {"msg":"method","method":"/mycoll/remove","params":[{"_id":"some-doc"}],"id":"1"}

What is now available, for example, is {"msg":"method","method":"/mycoll/find","params":[{"_id":"some-doc"}],"id":"1"}, however.

So is there any documentation as to what methods are available? I couldn't find any, and have only found those by trying lots of possibilities.


Solution

  • This is undocumented, but if you want to see a full list of all available methods you can add the following code to one of your server files within your Meteor app and it'll display a sorted list of all defined Meteor.methods handlers at the command line, including those for collections and packages:

    Meteor.startup(function() {
        console.log(Object.keys(Meteor.server.method_handlers).sort());
    });
    

    Granted, this doesn't provide any documentation, but it'll let you see what's available.