Skip to content

Document how to add remote method to a built-in model #763

@crandmck

Description

@crandmck

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):

  1. Create a boot script, eg. /server/boot/userRemoteMethods.js.
  2. 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'}
        }
    );
};

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions