@cheetah.js/orm 0.1.76 → 0.1.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -211,6 +211,7 @@ class SqlBuilder {
211
211
  return parseInt(result.query.rows[0].count);
212
212
  }
213
213
  logExecution(result) {
214
+ console.log(result.sql);
214
215
  this.logger.debug(`SQL: ${result.sql} [${Date.now() - result.startTime}ms]`);
215
216
  }
216
217
  async inTransaction(callback) {
@@ -40,5 +40,11 @@ export declare abstract class BaseEntity {
40
40
  [K in keyof T]: ValueOrInstance<T[K]>;
41
41
  }>): Promise<T>;
42
42
  save(): Promise<void>;
43
+ /**
44
+ * Determines whether the current object has been persisted after the last modification.
45
+ *
46
+ * @return {boolean} Returns true if the object has been persisted, otherwise false.
47
+ */
48
+ isPersisted(): boolean;
43
49
  toJSON(): Record<string, any>;
44
50
  }
@@ -15,12 +15,13 @@ class BaseEntity {
15
15
  return true;
16
16
  }
17
17
  // se oldvalue não existir, é porque é a primeira vez que o atributo está sendo setado
18
- if (!target._oldValues[p]) {
18
+ if (!(p in target._oldValues)) {
19
19
  target._oldValues[p] = newValue;
20
20
  }
21
21
  // se o valor for diferente do valor antigo, é porque o valor foi alterado
22
22
  if (target._oldValues[p] !== newValue) {
23
23
  target._changedValues[p] = newValue;
24
+ this.$_isPersisted = false;
24
25
  }
25
26
  target[p] = newValue;
26
27
  return true;
@@ -111,6 +112,14 @@ class BaseEntity {
111
112
  };
112
113
  this._changedValues = {};
113
114
  }
115
+ /**
116
+ * Determines whether the current object has been persisted after the last modification.
117
+ *
118
+ * @return {boolean} Returns true if the object has been persisted, otherwise false.
119
+ */
120
+ isPersisted() {
121
+ return this.$_isPersisted;
122
+ }
114
123
  toJSON() {
115
124
  let data = {};
116
125
  let storage = entities_1.EntityStorage.getInstance();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cheetah.js/orm",
3
- "version": "0.1.76",
3
+ "version": "0.1.78",
4
4
  "description": "A simple ORM for Cheetah.js",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",
@@ -55,5 +55,5 @@
55
55
  "bun",
56
56
  "value-object"
57
57
  ],
58
- "gitHead": "253d62e2b6a0d63016b730b3d72bb982c6e64825"
58
+ "gitHead": "2467c882fd8f4df6277957621fab117a70278f42"
59
59
  }