Skip to content

huttonr/meteor-methods

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

meteor-methods

ES6 import/export support for Meteor methods.

npm version

Installation

meteor npm install --save meteor-methods

Example Usage

// customerMethods.js
import { Method } from 'meteor-methods';
import { Customers } from '/lib/collections';

export const addCustomer = new Method('Customers_addCustomer', function (personName) {
  check(personName, String);
  
  if (Customers.findOne({personName})) {
    throw new Meteor.Error('Customer with that name already exists.');
  }
  
  return Customers.insert({personName, createdBy: this.userId});
});



// customersTemplate.js
import { addCustomer } from './customerMethods.js';

/*    ...    */

function onAddCustomerClick(personName) {
  addCustomer(personName, (err, res) => {
    if (err) {
      alert(`Error: ${ err.message }`);
    }
    
    alert(`Added customer with id: ${ res }`);
  });
}

About

ES6 import/export support for Meteor methods.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages