且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何指定Strongloop模型架构?

更新时间:2023-11-29 15:04:16

如果我理解的正确,您正在尝试在此部分显示返回的模型,如下所示:

If I understand you right, your'e trying to show at this section the returned model as follows:

[
  {
    "companyProperty1": "companyProperty1Type",
    "companyProperty2": "companyProperty2Type",
    .
    .
    "companyPropertyN": "companyPropertyNType",
  }
]

为了实现这种返回类型表示,您需要在remoteMethod选项中定义返回类型,以使其成为所需模型的数组.

In order to achieve this kind of return type representation, you need to define your return type in remoteMethod options to be an array of the desired model.

这是您的代码,使用 modelName进行了必要的编辑模型基类的属性:

Company.remoteMethod(
    'find',
    {
        accepts: {arg: 'msg', type: 'string'},
        returns: {type: [Company.modelName], root: true},
        http: {path: '/', verb:'get'}
    }
)