2.2.0
- New class property
meteorMethods
for defining Meteor methods that will be executed on the client and server like regular Meteor methods.
const User = Class.create({
name: User,
collection: Users,
fields: {
firstName: String,
lastName: String
},
meteorMethods: {
rename(first, last, invocation) {
// invocation.isSimulation;
// invocation.unblock();
this.firstName = first;
this.lastName = last;
this.save();
}
}
});
const u = User.findOne();
// Possible ways of invocations.
u.rename('John', 'Smith', (err, result) => {
});
u.callMethod('rename', 'John', 'Smith', (err, result) => {
});
u.applyMethod('rename', ['John', 'Smith'], (err, result) => {
});
You can read more about Meteor methods in docs
methods
have been renamed tohelpers
. You can still use themethods
property but it's deprecated and will be removed in the future Astronomy releases.