@mongez/mongodb
Advanced tools
Comparing version 1.0.26 to 1.0.27
@@ -186,2 +186,6 @@ import { ObjectId } from "mongodb"; | ||
/** | ||
* Determine whether the model should be updated or not | ||
*/ | ||
protected shouldUpdate(originalData: Schema, data: Schema): boolean; | ||
/** | ||
* Triggered before saving the model either by creating or updating | ||
@@ -188,0 +192,0 @@ */ |
@@ -294,3 +294,4 @@ "use strict"; | ||
// if not changed, then do not do anything | ||
// if (areEqual(this.originalData, this.data)) return this; | ||
if (this.shouldUpdate(this.originalData, this.data) === false) | ||
return this; | ||
currentModel = this.clone(); | ||
@@ -378,2 +379,8 @@ mode = "update"; | ||
/** | ||
* Determine whether the model should be updated or not | ||
*/ | ||
shouldUpdate(originalData, data) { | ||
return reinforcements.areEqual(originalData, data) === false; | ||
} | ||
/** | ||
* Triggered before saving the model either by creating or updating | ||
@@ -604,3 +611,3 @@ */ | ||
clone() { | ||
return new this.constructor(this.data); | ||
return new this.constructor({ ...this.data }); | ||
} | ||
@@ -607,0 +614,0 @@ } |
@@ -186,2 +186,6 @@ import { ObjectId } from "mongodb"; | ||
/** | ||
* Determine whether the model should be updated or not | ||
*/ | ||
protected shouldUpdate(originalData: Schema, data: Schema): boolean; | ||
/** | ||
* Triggered before saving the model either by creating or updating | ||
@@ -188,0 +192,0 @@ */ |
@@ -290,3 +290,4 @@ import { | ||
// if not changed, then do not do anything | ||
// if (areEqual(this.originalData, this.data)) return this; | ||
if (this.shouldUpdate(this.originalData, this.data) === false) | ||
return this; | ||
currentModel = this.clone(); | ||
@@ -371,2 +372,8 @@ mode = "update"; | ||
/** | ||
* Determine whether the model should be updated or not | ||
*/ | ||
shouldUpdate(originalData, data) { | ||
return areEqual(originalData, data) === false; | ||
} | ||
/** | ||
* Triggered before saving the model either by creating or updating | ||
@@ -595,3 +602,3 @@ */ | ||
clone() { | ||
return new this.constructor(this.data); | ||
return new this.constructor({ ...this.data }); | ||
} | ||
@@ -598,0 +605,0 @@ } |
{ | ||
"name": "@mongez/mongodb", | ||
"version": "1.0.26", | ||
"version": "1.0.27", | ||
"description": "Powerful Mongodb Database Manager for Node Js", | ||
@@ -9,10 +9,10 @@ "main": "./cjs/index.js", | ||
"@mongez/logger": "^1.0.6", | ||
"@mongez/reinforcements": "^2.3.0", | ||
"@mongez/reinforcements": "^2.3.1", | ||
"@mongez/supportive-is": "^1.0.12", | ||
"@mongez/time-wizard": "^1.0.0", | ||
"dayjs": "^1.11.7", | ||
"mongodb": "^5.2.0" | ||
"mongodb": "^5.3.0" | ||
}, | ||
"scripts": { | ||
"update": "ncu -u", | ||
"update": "npx ncu -u -x chalk", | ||
"fix:test": "eslint --fix -c ./.eslintrc.json ./tests", | ||
@@ -29,7 +29,7 @@ "format:test": "prettier --write ./tests/**/*.{js,jsx,ts,tsx,css,md,json} --config ./.prettierrc.json", | ||
"devDependencies": { | ||
"@types/jest": "^29.5.0", | ||
"@types/jest": "^29.5.1", | ||
"chalk": "4", | ||
"commander": "^10.0.0", | ||
"commander": "^10.0.1", | ||
"console-table-printer": "^2.11.1", | ||
"eslint": "^8.38.0", | ||
"eslint": "^8.39.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
@@ -39,3 +39,3 @@ "eslint-plugin-prettier": "^4.2.1", | ||
"jest": "^29.5.0", | ||
"npm-check-updates": "^16.10.8", | ||
"npm-check-updates": "^16.10.9", | ||
"prettier": "^2.8.7", | ||
@@ -42,0 +42,0 @@ "prettier-plugin-organize-imports": "^3.2.2", |
338612
12703
Updatedmongodb@^5.3.0