angular - 使用角度服务更新多行的正确方法
问题描述
试图了解这应该如何工作。我正在使用弹簧微服务设置,这个角度服务调用更新了一条记录:
角服务:
save(recordModel) {
recordModel.lastUpdated = new Date();
recordModel.whoUpdated = this.loginService.getUserId();
this.dataService.httpPut(recordModel._links.self.href, recordModel).subscribe(resp => { },
(resp) => {
this.logger.error("Save Failed", resp);
this.dialogError(resp);
});
}
我需要能够更新数据库中所有记录的某些 json 属性:
updateAttributeIds(interfaceName: string) {
this.logger.info("Updating Attribute Id's");
let syncIssues = 0;
for (let i = 0; i < this.dataSource.length; i++) {
if(this.dataSource[i].attributes.attributeId != this.dataSource[i].id) {
syncIssues ++;
if(this.dataSource[i].attributes.interfaceName === interfaceName) {
this.dataSource[i].attributes.attributeId = this.dataSource[i].id;
this.logger.info("Updating", this.dataSource[i].id);
this.save(this.dataSource[i]);
}
}
}
this.logger.warn("Updating Attribute Id's", syncIssues);
}
这似乎有效,但是 this.save(this.dataSource[i]); 不等待承诺,如果需要,我会尝试在它尝试更新下一条记录之前弄清楚它。感觉就像在一个大型数据集上,最终我会耗尽资源 - 或线程?只是不清楚到底发生了什么。
谢谢
解决方案
推荐阅读
- c# - 用于 c# WPF 的 Microcharts 中的简单圆环图
- flutter - 如何将背景图像添加到颤动
- vba - 如何将 VBA responseText 转换为用户定义的元组?
- visual-studio - 错误“Keras 需要 TensorFlow 2.2 或更高版本”
- react-native - Appium 的 accessId/TestID 不适用于 react-navigation 的 headerTransparent 属性
- javascript - 如何将日期(yyyy/MM/dd)转换为日期并返回字符串
- node.js - 后端 (NodeJS) - Adaptivecard JSON 到 HTML 解析器
- springdoc - 如何设置 OAuth2.0 请求标头
- r - 从列表列表中提取标签
- security - 安全问题:Azure AKS omsagent pod 以 root 用户身份运行。如何应用额外的硬化?