mirror of
https://github.com/cool-team-official/cool-admin-midway-packages.git
synced 2025-12-12 14:22:49 +00:00
优化save模式下的更新操作
This commit is contained in:
parent
41b886e055
commit
d65ee69b8c
@ -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",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cool-midway/core",
|
||||
"version": "7.0.4",
|
||||
"version": "7.0.6",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"typings": "index.d.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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user