gpt4 book ai didi

node.js - 环回浏览器内联模型想要模型架构

转载 作者:太空宇宙 更新时间:2023-11-04 00:27:49 25 4
gpt4 key购买 nike

我的 RemoteMethods 无法在 Loopback Explorer 中显示默认值。如果我输入 JSON 对象,就会创建该帖子,但通常会有一个标记为“模型架构”的示例。这里只是说内联模型。

有什么想法吗?

模型定义:

{
"name": "PicklistModel",
"plural": "PicklistModels",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"picklistId": {
"type": "string",
"id": true,
"generated": true
},
"key": {
"type": "string",
"required": false
},
"value": {
"type": "string",
"required": false
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}

远程方法定义:

 Picklist.remoteMethod('create', {
description: 'Create an PICKLIST',
http: {
path: '/',
verb: 'POST'
},
accepts : [{
description : 'The request to create an PICKLIST',
arg : 'request',
type : 'object',
required : true,
http : {
source : 'body'
},
default: {
key: '',
value: ''
}
}
],
returns: RESTResponseStatic.loopbackAdapterCommonRestResponseDefinition()
});

Loopback Explorer

最佳答案

使用参数类型来建模类型而不是对象,请参见下面的示例

 accepts: [{
description : 'The request to create an PICKLIST',
arg: 'request',
type: 'Picklist', // *** give model reference here
required : true,
http: {
source : 'body'
},
default: {
key: '',
value: ''
}
}]

关于node.js - 环回浏览器内联模型想要模型架构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42122374/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com