优化save模式下的更新操作

This commit is contained in:
cool 2023-12-20 19:16:31 +08:00
parent 41b886e055
commit d65ee69b8c
3 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@cool-midway/core", "name": "@cool-midway/core",
"version": "7.0.4", "version": "7.0.6",
"description": "", "description": "",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "index.d.ts", "typings": "index.d.ts",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cool-midway/core", "name": "@cool-midway/core",
"version": "7.0.4", "version": "7.0.6",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"typings": "index.d.ts", "typings": "index.d.ts",

View File

@ -340,6 +340,13 @@ export abstract class BaseService {
} else{ } else{
const upsert = this._coolConfig.crud?.upsert || 'normal'; const upsert = this._coolConfig.crud?.upsert || 'normal';
if (type == 'update') { if (type == 'update') {
if(upsert == 'save') {
const info = await this.entity.findOneBy({id: param.id})
param = {
...info,
...param
}
}
param.updateTime = new Date(); param.updateTime = new Date();
upsert == 'normal'? await this.entity.update(param.id, param): await this.entity.save(param); upsert == 'normal'? await this.entity.update(param.id, param): await this.entity.save(param);
} }