如何在回环中定义单独的隐藏道具



我希望在loopback explorer中看到一些道具,但我不想向他们展示post方法,例如id属性。如何在循环中完成?

没有内置方法。

您需要在远程之后对每个远程方法进行与默认方法不同的方法。

Model.afterRemote('GetMethod', function(ctx, instance, next){
  var instance = ctx.result;
  //reshape it
  ctx.result = instance;
  next();
});

update

如果您想在Explorer组件中影响这一点,因此您需要使用null DataSource创建单独的模型,以显示架构并在远程方法的定义中使用该模型。

Model.remoteMethod('GetMethod', {
    accepts: [
      {
        arg: 'req',
        type: 'Object',
        required: true,
        http: {source: 'req'}
      }
    ],
    returns: {root: true, type: 'ModelDTOForSHow'},
    http: {verb: 'get', status: 200, path: '/getter'}
  });

,在ModelDTOForShow中,您隐藏了一些道具,在另一个道具中,其他一些道具

最新更新