Skip to content

Commit f0ab446

Browse files
authored
fix(core): reduce the updateById 3 DB calls to 2 (#36)
* fix(core): reduce the updateById 3 DB calls to 2 GH-33 * docs(ci-cd): added PR template GH-33
1 parent 88ccf8a commit f0ab446

3 files changed

Lines changed: 35 additions & 4 deletions

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Description
2+
3+
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
4+
5+
Fixes # (issue)
6+
7+
## Type of change
8+
9+
Please delete options that are not relevant.
10+
11+
- [ ] Bug fix (non-breaking change which fixes an issue)
12+
- [ ] New feature (non-breaking change which adds functionality)
13+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
14+
- [ ] Intermediate change (work in progress)
15+
16+
## How Has This Been Tested?
17+
18+
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
19+
20+
- [ ] Test A
21+
- [ ] Test B
22+
23+
## Checklist:
24+
25+
- [ ] Performed a self-review of my own code
26+
- [ ] npm test passes on your machine
27+
- [ ] New tests added or existing tests modified to cover all changes
28+
- [ ] Code conforms with the style guide
29+
- [ ] API Documentation in code was updated
30+
- [ ] Any dependent changes have been merged and published in downstream modules

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mixins/audit.mixin.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
EntityCrudRepository,
77
Where,
88
} from '@loopback/repository';
9-
import {keyBy} from 'lodash';
9+
import {keyBy, cloneDeep} from 'lodash';
1010

1111
import {Action, AuditLog} from '../models';
1212
import {AuditLogRepository} from '../repositories';
@@ -202,7 +202,8 @@ export function AuditRepositoryMixin<
202202
options = {noAudit: true};
203203
}
204204
await super.updateById(id, data, options);
205-
const after = await this.findById(id);
205+
let after = cloneDeep(before);
206+
after = Object.assign(after, data);
206207

207208
if (this.getCurrentUser) {
208209
const user = await this.getCurrentUser();

0 commit comments

Comments
 (0)