Currently, we document how to define a remote method for a custom model, and how to create a custom model that extends a built-in model (to which you could attach a remote method) but NOT how to attach a remote method directly to a built-in model.
Summary (example):
- Create a boot script, eg.
/server/boot/userRemoteMethods.js.
- Add the following to this file:
User = app.models.User;
module.exports = function(User){
User.greet = function(msg, cb) {
cb(null, 'Greetings... ' + msg);
}
User.remoteMethod(
'greet',
{
accepts: {arg: 'msg', type: 'string'},
returns: {arg: 'greeting', type: 'string'}
}
);
};