loopback icon indicating copy to clipboard operation
loopback copied to clipboard

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

Open mackwan84 opened this issue 11 years ago • 2 comments

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

mackwan84 avatar Jul 03 '15 04:07 mackwan84

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: '/'}
  });

raymondfeng avatar Jul 03 '15 06:07 raymondfeng

See https://github.com/strongloop/loopback/issues/491

raymondfeng avatar Jul 03 '15 06:07 raymondfeng