sync数据的bug
This commit is contained in:
parent
e2d78d6083
commit
c9a04611c5
37
es/store.js
37
es/store.js
|
|
@ -1948,23 +1948,26 @@ export default class TreeStore extends CascadeStore {
|
|||
default: {
|
||||
const { e, d, f } = record;
|
||||
assert(d[UpdateAtAttribute], `获取的${e}对象数据没有update时间戳`);
|
||||
if (!this.store[e]?.[d.id]) {
|
||||
this.updateAbjointRow(e, {
|
||||
id: 'dummy',
|
||||
action: 'create',
|
||||
data: d,
|
||||
}, context, option2);
|
||||
this.addToOperationResult(result, e, 'create');
|
||||
}
|
||||
else if (this.store[e][d.id].$current?.[UpdateAtAttribute] <= d[UpdateAtAttribute]) {
|
||||
this.updateAbjointRow(e, {
|
||||
id: 'dummy',
|
||||
action: 'update',
|
||||
data: d,
|
||||
filter: f,
|
||||
}, context, option2);
|
||||
this.addToOperationResult(result, e, 'update');
|
||||
}
|
||||
// 只更新满足条件的行的更新时间戳比自己小的(BM项目中出现过socket推送的状态先回的情况)
|
||||
const cur = this.selectAbjointRow(e, {
|
||||
data: {
|
||||
id: 1,
|
||||
[UpdateAtAttribute]: 1,
|
||||
},
|
||||
filter: f,
|
||||
}, context, {});
|
||||
const ids = cur.filter(row => row[UpdateAtAttribute] <= d[UpdateAtAttribute]).map(row => row.id);
|
||||
this.updateAbjointRow(e, {
|
||||
id: 'dummy',
|
||||
action: 'update',
|
||||
data: d,
|
||||
filter: {
|
||||
id: {
|
||||
$in: ids,
|
||||
}
|
||||
},
|
||||
}, context, option2);
|
||||
this.addToOperationResult(result, e, 'update');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
37
lib/store.js
37
lib/store.js
|
|
@ -1950,23 +1950,26 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
default: {
|
||||
const { e, d, f } = record;
|
||||
(0, assert_1.assert)(d[Entity_1.UpdateAtAttribute], `获取的${e}对象数据没有update时间戳`);
|
||||
if (!this.store[e]?.[d.id]) {
|
||||
this.updateAbjointRow(e, {
|
||||
id: 'dummy',
|
||||
action: 'create',
|
||||
data: d,
|
||||
}, context, option2);
|
||||
this.addToOperationResult(result, e, 'create');
|
||||
}
|
||||
else if (this.store[e][d.id].$current?.[Entity_1.UpdateAtAttribute] <= d[Entity_1.UpdateAtAttribute]) {
|
||||
this.updateAbjointRow(e, {
|
||||
id: 'dummy',
|
||||
action: 'update',
|
||||
data: d,
|
||||
filter: f,
|
||||
}, context, option2);
|
||||
this.addToOperationResult(result, e, 'update');
|
||||
}
|
||||
// 只更新满足条件的行的更新时间戳比自己小的(BM项目中出现过socket推送的状态先回的情况)
|
||||
const cur = this.selectAbjointRow(e, {
|
||||
data: {
|
||||
id: 1,
|
||||
[Entity_1.UpdateAtAttribute]: 1,
|
||||
},
|
||||
filter: f,
|
||||
}, context, {});
|
||||
const ids = cur.filter(row => row[Entity_1.UpdateAtAttribute] <= d[Entity_1.UpdateAtAttribute]).map(row => row.id);
|
||||
this.updateAbjointRow(e, {
|
||||
id: 'dummy',
|
||||
action: 'update',
|
||||
data: d,
|
||||
filter: {
|
||||
id: {
|
||||
$in: ids,
|
||||
}
|
||||
},
|
||||
}, context, option2);
|
||||
this.addToOperationResult(result, e, 'update');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
42
src/store.ts
42
src/store.ts
|
|
@ -2318,23 +2318,31 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
default: {
|
||||
const { e, d, f } = record as UpdateOpResult<ED, keyof ED>;
|
||||
assert(d[UpdateAtAttribute], `获取的${e as string}对象数据没有update时间戳`);
|
||||
if (!this.store[e]?.[d.id!]) {
|
||||
this.updateAbjointRow(e, {
|
||||
id: 'dummy',
|
||||
action: 'create',
|
||||
data: d,
|
||||
}, context, option2);
|
||||
this.addToOperationResult(result, e, 'create');
|
||||
}
|
||||
else if (this.store[e]![d.id].$current?.[UpdateAtAttribute] <= d[UpdateAtAttribute]) {
|
||||
this.updateAbjointRow(e, {
|
||||
id: 'dummy',
|
||||
action: 'update',
|
||||
data: d,
|
||||
filter: f,
|
||||
}, context, option2);
|
||||
this.addToOperationResult(result, e, 'update');
|
||||
}
|
||||
|
||||
// 只更新满足条件的行的更新时间戳比自己小的(BM项目中出现过socket推送的状态先回的情况)
|
||||
const cur = this.selectAbjointRow(e, {
|
||||
data: {
|
||||
id: 1,
|
||||
[UpdateAtAttribute]: 1,
|
||||
},
|
||||
filter: f,
|
||||
}, context, {});
|
||||
const ids = cur.filter(
|
||||
row => row[UpdateAtAttribute] <= d[UpdateAtAttribute]
|
||||
).map(
|
||||
row => row.id!
|
||||
);
|
||||
this.updateAbjointRow(e, {
|
||||
id: 'dummy',
|
||||
action: 'update',
|
||||
data: d,
|
||||
filter: {
|
||||
id: {
|
||||
$in: ids,
|
||||
}
|
||||
},
|
||||
}, context, option2);
|
||||
this.addToOperationResult(result, e, 'update');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue