Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I group methods in Meteor?

Tags:

meteor

I'm starting with Meteor, and want to organize my methods... By example, I have 2 collecations: 'a' and 'b', both have the insert method.. I want to do something like that:

Meteor.methods({
    a: {
        insert : function(){
           console.log("insert in Collection a");
        }
      },
    b: {
        insert : function(){
           console.log("insert in Collection b");
        }
      }
});

And then call
Meteor.call('a.insert');

It's possible to do this? Or how can I organize my methods?

I don't wanna make methods like: 'insertA' and 'insertB'

like image 888
thur Avatar asked Sep 18 '15 03:09

thur


1 Answers

You could use this syntax :

Meteor.methods({
  "a.insert": function(){
    console.log("insert in Collection a");
  }
  "b.insert": function(){
    console.log("insert in Collection b");
  }
});

Which allows you to do Meteor.call("a.insert");.

like image 146
saimeunt Avatar answered Nov 13 '22 15:11

saimeunt