【发布时间】:2021-05-23 05:12:39
【问题描述】:
我在 Angular 项目中使用 json-server 模拟 REST API。适用于除 DELETE 之外的所有内容,其中包含多个 ID 列的任何和所有我的 json 对象都会在发出 DELETE 请求时被删除。
假设我有以下一组具有相关“accountId”ID 列的对象:
"accountfiles": [{
id: 9001,
accountId: 1001,
filename: 'test.docx',
}, {
id: 9002,
accountId: 1002,
filename: 'test.txt',
}, {
id: 9003,
accountId: 1001,
filename: 'taxes.pdf',
}, {
id: 9004,
accountId: 1003,
filename: 'layout.ppt',
}, {
id: 9005,
accountId: 1002,
filename: 'Spreadsheet 5.xlsx',
}
)];
这些可在以下位置获得:
http://localhost:3000/accountfiles
然后我删除了这个单独的对象:
http://localhost:3000/accountfiles/1001
删除整个集合以及包含多个 ID 列的所有其他集合。
此外,如果我有一个 Account 类:
"account": [
{
"id": 1001,
"isInactive": false,
"name": "HK Asset Group",
"accountLogoUrl": "/assets/img/logos/logo2.png",
"location": "Minneapolis MN 55434"
}
]
并且我删除了账号id:1001,整个accountfiles集合也被删除了。
我尝试使用 --no-cascade-delete 启动标志无济于事(似乎不是当前 json-server 构建的一部分)。
难道不能在 json-server 中托管相关数据并进行有效删除吗?
谢谢
【问题讨论】:
-
这里有同样的问题。你解决了吗?
标签: json-server