Skip to content

Commit

Permalink
FIX save for update method
Browse files Browse the repository at this point in the history
  • Loading branch information
stombre committed Mar 22, 2020
1 parent 16b3486 commit 8823594
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions lib/model/baseModel.classFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,11 @@ const injectIlorm = ilorm => {
// If something need to be updated:
const query = this.getQueryPrimary();

const update = this[LIST_UPDATED_FIELDS].reduce((finalUpdate, property) => {
finalUpdate[property] = this[property];

return finalUpdate;
}, {});
this[LIST_UPDATED_FIELDS].forEach(field => {
query[field].set(this[field]);
});

await this.constructor.getConnector().updateOne(query, update);
await this.constructor.getConnector().updateOne(query);

this[LIST_UPDATED_FIELDS] = [];

Expand Down
2 changes: 1 addition & 1 deletion lib/query/baseQuery.classFactory/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ const injectIlorm = ilorm => {
updateBuilder({ onOperator, }) {
if (onOperator) {
for (const { field, operator, value, } of this[UPDATE]) {
onOperator(field, operator, value);
onOperator({ field, operator, value });
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ilorm",
"version": "0.3.0",
"version": "0.3.1",
"description": "Core package of ilorm ORM",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 8823594

Please sign in to comment.