我使用命令创建了一个模型: slc loopback:model
我没有更改任何其他内容,因此model.js是默认值,而model.json是默认值。模型暴露在其余的api上,并出现在api explorer中。 如果我运行GET它会根据需要返回3个coffeeshops,然后当我尝试删除其中一个商店时,无论是通过资源管理器还是CURL,我都会获得501状态代码。 我一整天都在阅读文档,并没有告诉我deleteById调用将被禁用,只有deleteAll调用。 我错过了什么吗?我应该在某处为自定义模型启用删除吗?我已经扩展了用户模型并对100%
进行了删除这是api资源管理器的截图和返回的501错误。您可以看到我传递了id,它只返回501.第二个图像显示控制台输出。
这里要求的是我的coffee-shop.json
{
"name": "CoffeeShop",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"name": {
"type": "string",
"required": true
},
"city": {
"type": "string",
"required": true
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
还有model-config.json
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../common/models",
"./models"
],
"mixins": [
"loopback/common/mixins",
"loopback/server/mixins",
"../common/mixins",
"./mixins"
]
},
"User": {
"dataSource": "db"
},
"AccessToken": {
"dataSource": "db",
"public": false
},
"ACL": {
"dataSource": "db",
"public": false
},
"RoleMapping": {
"dataSource": "db",
"public": false
},
"Role": {
"dataSource": "db",
"public": false
},
"CoffeeShop": {
"dataSource": "oracleDS",
"public": true
}
}
哦,我的npm版本是3.10.8 节点v6.9.1 和slc --version
strongloop v6.0.3 (node v6.9.1) ├── strong-arc@1.8.9 (3dd25ac) ├── strong-build@2.1.2 (a98f310) ├── strong-deploy@3.1.4 (9b29df0) ├── strong-mesh-models@8.1.0 (62e539b) ├── strong-pm@5.2.3 ├── strong-registry@1.1.6 (f8c2339) ├── strong-start@1.3.4 (28c261d) ├─┬ strong-supervisor@3.3.3 │ └── strong-agent@2.1.1 (b51fc45) ├── generator-loopback@1.25.0 (6a0e2c0) ├── node-inspector@0.7.4 └── nodefly-register@0.3.3