LoopbackJS 3.x,如何启用删除所有匹配实例的功能 [英] LoopbackJS 3.x, how to enable delete all matching instances

查看:57
本文介绍了LoopbackJS 3.x,如何启用删除所有匹配实例的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过默认环回删除所有匹配的实例不会通过REST API公开. 如何启用它?

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

推荐答案

我找不到对文档的任何引用,但是我成功地对此进行了测试.

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

TLDR: 将其放在您的model.jsserver.js

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,
        });

上面只是来自,但shared: false被注释掉.

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

这篇关于LoopbackJS 3.x,如何启用删除所有匹配实例的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆