From d65ee69b8c738773c59f08ac9bf8f622d37a1699 Mon Sep 17 00:00:00 2001 From: cool Date: Wed, 20 Dec 2023 19:16:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96save=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E6=9B=B4=E6=96=B0=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/package.json | 2 +- core/src/package.json | 2 +- core/src/service/base.ts | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/package.json b/core/package.json index 9c3bd50..f1aedff 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@cool-midway/core", - "version": "7.0.4", + "version": "7.0.6", "description": "", "main": "dist/index.js", "typings": "index.d.ts", diff --git a/core/src/package.json b/core/src/package.json index 4dcf6f2..1f94dfa 100644 --- a/core/src/package.json +++ b/core/src/package.json @@ -1,6 +1,6 @@ { "name": "@cool-midway/core", - "version": "7.0.4", + "version": "7.0.6", "description": "", "main": "index.js", "typings": "index.d.ts", diff --git a/core/src/service/base.ts b/core/src/service/base.ts index 2affdef..d6befcc 100644 --- a/core/src/service/base.ts +++ b/core/src/service/base.ts @@ -340,6 +340,13 @@ export abstract class BaseService { } else{ const upsert = this._coolConfig.crud?.upsert || 'normal'; if (type == 'update') { + if(upsert == 'save') { + const info = await this.entity.findOneBy({id: param.id}) + param = { + ...info, + ...param + } + } param.updateTime = new Date(); upsert == 'normal'? await this.entity.update(param.id, param): await this.entity.save(param); }