空update时不生成modi

This commit is contained in:
Xu Chang 2024-08-30 14:18:21 +08:00
parent 5408c68892
commit 957611b9ab
2 changed files with 17 additions and 7 deletions

View File

@ -1229,7 +1229,12 @@ class CascadeStore extends RowStore_1.RowStore {
// 变成对modi的插入
// 优化这里如果是对同一个targetEntity反复update则变成对最后一条create/update的modi进行update以避免发布文章这样的需求时产生过多的modi
let modiUpsert;
if (action !== 'remove') {
if (action === 'update') {
// 如果action本身是update且没有实际update属性这里可以忽略
const updateAttrCount = Object.keys(data).length;
if (updateAttrCount === 0) {
return {};
}
const upsertModis = await this.selectAbjointRowAsync('modi', {
data: {
id: 1,

View File

@ -403,14 +403,14 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
selection: ED[T]['Selection'],
context: Cxt,
option: OP): Partial<ED[T]['Schema']>[];
protected abstract countAbjointRow<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(
entity: T,
selection: Pick<ED[T]['Selection'], 'filter' | 'count'>,
context: Cxt,
option: OP): number;
protected abstract countAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(
entity: T,
selection: Pick<ED[T]['Selection'], 'filter' | 'count'>,
@ -914,7 +914,7 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
option2.modiParentId = data.id;
option2.modiParentEntity = entity as string;
}
else if (filter?.id && typeof filter.id === 'string'){
else if (filter?.id && typeof filter.id === 'string') {
// 如果是对toModi对象进行cascadeUpdate操作必然带有id如果没有则认为不是modi相关的操作
// 批量通过或者拒绝applyment应该就会出现
option2.modiParentId = filter.id;
@ -1048,7 +1048,7 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
() => cascadeUpdate.call(this, relation, operationMto, context, option2)
);
}
else if (relation instanceof Array){
else if (relation instanceof Array) {
const [entityOtm, foreignKey] = relation;
const otmOperations = data[attr];
const dealWithOneToMany = (otm: ED[keyof ED]['Update'] | ED[keyof ED]['Create']) => {
@ -1503,7 +1503,12 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
// 变成对modi的插入
// 优化这里如果是对同一个targetEntity反复update则变成对最后一条create/update的modi进行update以避免发布文章这样的需求时产生过多的modi
let modiUpsert: CreateModiOperation | UpdateModiOperation | undefined;
if (action !== 'remove') {
if (action === 'update') {
// 如果action本身是update且没有实际update属性这里可以忽略
const updateAttrCount = Object.keys(data).length;
if (updateAttrCount === 0) {
return {};
}
const upsertModis = await this.selectAbjointRowAsync('modi', {
data: {
id: 1,