0.3.0 • Published 4 years ago

meteor-methods v0.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

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 { testMethod } from './customerMethods.js';

/*    ...    */

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

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago