LoopbackJS 3.x, how to enable delete all matching instances

别来无恙 提交于 2019-12-24 07:45:01

问题


By default in Loopback delete all matching instances is not exposed over REST API. How to enable it?


回答1:


I couldn't find any reference to the documentation, but I successfully tested this.

TLDR: Put in this in your model.js or in server.js

app.models.<model>.remoteMethod('destroyAll', {
          description: 'Delete all matching records.',
          accessType: 'WRITE',
          accepts: [
            {arg: 'where', type: 'object', description: 'filter.where object'},
            {arg: 'options', type: 'object', http: 'optionsFromRequest'},
          ],
          returns: {
            arg: 'count',
            type: 'object',
            description: 'The number of instances deleted',
            root: true,
          },
          http: {verb: 'del', path: '/'},
          // shared: false,
        });

The above is simply the remote method declaration from the source, except the shared: false is commented out.



来源:https://stackoverflow.com/questions/49858943/loopbackjs-3-x-how-to-enable-delete-all-matching-instances

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!