diff --git a/es/store.js b/es/store.js index f474df1..d14a3db 100644 --- a/es/store.js +++ b/es/store.js @@ -147,13 +147,12 @@ export default class TreeStore extends CascadeStore { this.seq = {}; } constructRow(node, context, option) { - let data = cloneDeep(node.$current); if (context.getCurrentTxnId() && node.$txnId === context.getCurrentTxnId()) { if (!node.$next) { // 如果要求返回delete数据,返回带$$deleteAt$$的行 // bug fixed,这里如果是自己create再删除,data也是null - if (data && option?.includedDeleted) { - return Object.assign({}, data, { + if (node.$current && option?.includedDeleted) { + return Object.assign({}, node.$current, { [DeleteAtAttribute]: 1, }); } @@ -161,19 +160,21 @@ export default class TreeStore extends CascadeStore { } else if (!node.$current) { // 本事务创建的,若在cache中$$createAt$$和$$updateAt$$置为1 - return Object.assign({}, data, node.$next, context instanceof SyncContext && { + return Object.assign({}, node.$current, node.$next, context instanceof SyncContext && { [CreateAtAttribute]: 1, [UpdateAtAttribute]: 1, }); } else { // 本事务更新的,若在cache中$$updateAt$$置为1 - return Object.assign({}, data, node.$next, context instanceof SyncContext && { + return Object.assign({}, node.$current, node.$next, context instanceof SyncContext && { [UpdateAtAttribute]: 1, }); } } - return data; + return { + ...node.$current, + }; } testFilterFns(node, nodeDict, exprResolveFns, fns) { const { self, otm, mto } = fns; diff --git a/lib/store.js b/lib/store.js index 1fd3787..526ae0f 100644 --- a/lib/store.js +++ b/lib/store.js @@ -149,13 +149,12 @@ class TreeStore extends CascadeStore_1.CascadeStore { this.seq = {}; } constructRow(node, context, option) { - let data = (0, lodash_1.cloneDeep)(node.$current); if (context.getCurrentTxnId() && node.$txnId === context.getCurrentTxnId()) { if (!node.$next) { // 如果要求返回delete数据,返回带$$deleteAt$$的行 // bug fixed,这里如果是自己create再删除,data也是null - if (data && option?.includedDeleted) { - return Object.assign({}, data, { + if (node.$current && option?.includedDeleted) { + return Object.assign({}, node.$current, { [Entity_1.DeleteAtAttribute]: 1, }); } @@ -163,19 +162,21 @@ class TreeStore extends CascadeStore_1.CascadeStore { } else if (!node.$current) { // 本事务创建的,若在cache中$$createAt$$和$$updateAt$$置为1 - return Object.assign({}, data, node.$next, context instanceof SyncRowStore_1.SyncContext && { + return Object.assign({}, node.$current, node.$next, context instanceof SyncRowStore_1.SyncContext && { [Entity_1.CreateAtAttribute]: 1, [Entity_1.UpdateAtAttribute]: 1, }); } else { // 本事务更新的,若在cache中$$updateAt$$置为1 - return Object.assign({}, data, node.$next, context instanceof SyncRowStore_1.SyncContext && { + return Object.assign({}, node.$current, node.$next, context instanceof SyncRowStore_1.SyncContext && { [Entity_1.UpdateAtAttribute]: 1, }); } } - return data; + return { + ...node.$current, + }; } testFilterFns(node, nodeDict, exprResolveFns, fns) { const { self, otm, mto } = fns; diff --git a/src/store.ts b/src/store.ts index f81328e..3ec0987 100644 --- a/src/store.ts +++ b/src/store.ts @@ -233,7 +233,7 @@ export default class TreeStore extends C } else if (!node.$current) { // 本事务创建的,若在cache中$$createAt$$和$$updateAt$$置为1 - return Object.assign({}, node.$next, context instanceof SyncContext && { + return Object.assign({}, node.$current, node.$next, context instanceof SyncContext && { [CreateAtAttribute]: 1, [UpdateAtAttribute]: 1, }); @@ -242,7 +242,7 @@ export default class TreeStore extends C // 本事务更新的,若在cache中$$updateAt$$置为1 return Object.assign({}, node.$current, node.$next, context instanceof SyncContext && { [UpdateAtAttribute]: 1, - }); + }) } } return {