gpt4 book ai didi

node.js - 尝试在处于 root.deleted.inFlight 状态时处理 上的事件 `pushedData`

转载 作者:搜寻专家 更新时间:2023-11-01 00:17:04 27 4
gpt4 key购买 nike

我有一个用于博客帖子的基本 crud 应用程序。控制台中出现上述错误。在我删除帖子后。但是帖子已从数据库中删除。我搜索了类似的问题,但没有一个答案解决了这个问题.我使用 JSONAPIAdapter 进行原始操作。

I checked the ember inspector for the flags and the flag for isDeleted is set to true.FYI the number of records shown in ember data is precise.

deletePost:function(id){
var self = this;
this.get('store').find('post', id)
.then(post => post.destroyRecord())
.then(() => self.transitionToRoute('posts'));
}

我使用 nodejs 作为后端,mysql 作为数据库。删除记录后,我发送这样的响应 res.status(204).end();

Ember CLI version 2.6.3

enter image description here

图中上面的细节是服务器的响应。 enter image description here

最佳答案

我很确定这个问题是由 ember 数据的后台重新加载引起的。即使对 api 的查找请求在删除请求之前被触发,查找请求也会在您触发删除请求后得到解决。要禁用后台重新加载并强制调用 api,您可以将 {reload: true} 传递给 findRecord() 调用。这将确保查找请求在您触发删除请求之前得到解决。

像这样:

deletePost(id) {
this.get('store').findRecord('post', id, { reload: true }).then((post) => {
return post.destroyRecord();
}).then(() => {
self.transitionToRoute('posts');
});
}

您可以在此处阅读有关 findRecord 的更多信息:http://emberjs.com/api/data/classes/DS.Store.html#method_findRecord

以后,我建议不要使用箭头函数简写,因为即使您不想返回值,它也会始终返回。

关于node.js - 尝试在处于 root.deleted.inFlight 状态时处理 <appname@model:post::ember622:17> 上的事件 `pushedData`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39193633/

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