Loopback: TypeError when I try to set the destroyAll method to be shared in REST API

Created on 3 Jul 2015  路  2Comments  路  Source: strongloop/loopback

When I try to set this code,

MyModel.sharedClass.find('destroyAll', true).shared = true;

it always throws this error:

TypeError: Cannot set property 'shared' of null

Most helpful comment

destroyAll is not a shared method. You can use MyMode.remoteMethod() as follows:

MyModel.remoteMethod('destroyAll', {
    isStatic: true,
    description: 'Delete all matching records',
    accessType: 'WRITE',
    accepts: {arg: 'where', type: 'object', description: 'filter.where object'},
    http: {verb: 'del', path: '/'}
  });

All 2 comments

destroyAll is not a shared method. You can use MyMode.remoteMethod() as follows:

MyModel.remoteMethod('destroyAll', {
    isStatic: true,
    description: 'Delete all matching records',
    accessType: 'WRITE',
    accepts: {arg: 'where', type: 'object', description: 'filter.where object'},
    http: {verb: 'del', path: '/'}
  });
Was this page helpful?
0 / 5 - 0 ratings