pinia-orm-edge 1.9.0-28580959.70a2cd0 → 1.9.0-28581943.45f87aa
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.
- package/dist/index.cjs +19 -40
- package/dist/index.mjs +19 -40
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
@@ -1449,7 +1449,8 @@ class Query {
|
|
1449
1449
|
if (isDeleting === false) {
|
1450
1450
|
notDeletableIds.push(currentModel.$getIndexId());
|
1451
1451
|
} else {
|
1452
|
-
this.hydratedDataCache.delete(this.model.$entity() + currentModel.$getIndexId());
|
1452
|
+
this.hydratedDataCache.delete("set" + this.model.$entity() + currentModel.$getIndexId());
|
1453
|
+
this.hydratedDataCache.delete("get" + this.model.$entity() + currentModel.$getIndexId());
|
1453
1454
|
afterHooks.push(() => currentModel.$self().deleted(currentModel));
|
1454
1455
|
this.checkAndDeleteRelations(currentModel);
|
1455
1456
|
}
|
@@ -1481,19 +1482,21 @@ class Query {
|
|
1481
1482
|
* an update event trigger in vue if the object is used.
|
1482
1483
|
*/
|
1483
1484
|
getHydratedModel(record, options) {
|
1484
|
-
const id = this.model.$getKey(record, true);
|
1485
|
-
const
|
1486
|
-
|
1485
|
+
const id = this.model.$entity() + this.model.$getKey(record, true);
|
1486
|
+
const operationId = options?.operation + id;
|
1487
|
+
let savedHydratedModel = this.hydratedDataCache.get(operationId);
|
1488
|
+
if (options?.action === "update") {
|
1489
|
+
this.hydratedDataCache.delete("get" + id);
|
1490
|
+
savedHydratedModel = void 0;
|
1491
|
+
}
|
1492
|
+
if (!this.getNewHydrated && savedHydratedModel) {
|
1487
1493
|
return savedHydratedModel;
|
1488
1494
|
}
|
1489
1495
|
const modelByType = this.model.$types()[record[this.model.$typeKey()]];
|
1490
1496
|
const getNewInsance = (newOptions) => (modelByType ? modelByType.newRawInstance() : this.model).$newInstance(record, { relations: false, ...options || {}, ...newOptions });
|
1491
1497
|
const hydratedModel = getNewInsance();
|
1492
|
-
if (
|
1493
|
-
this.hydratedDataCache.set(
|
1494
|
-
}
|
1495
|
-
if (id && options?.action === "update") {
|
1496
|
-
this.hydratedDataCache.set(this.model.$entity() + id, getNewInsance({ operation: "get" }));
|
1498
|
+
if (Utils.isEmpty(this.eagerLoad) && options?.operation !== "set") {
|
1499
|
+
this.hydratedDataCache.set(operationId, hydratedModel);
|
1497
1500
|
}
|
1498
1501
|
return hydratedModel;
|
1499
1502
|
}
|
@@ -3187,12 +3190,18 @@ class Model {
|
|
3187
3190
|
continue;
|
3188
3191
|
}
|
3189
3192
|
const attr = fields[key];
|
3190
|
-
|
3193
|
+
let value = attributes[key];
|
3191
3194
|
if (attr instanceof Relation && !fillRelation) {
|
3192
3195
|
continue;
|
3193
3196
|
}
|
3194
3197
|
const mutator = mutators?.[key];
|
3195
3198
|
const cast = this.$casts()[key]?.newRawInstance(fields);
|
3199
|
+
if (mutator && operation === "get") {
|
3200
|
+
value = typeof mutator === "function" ? mutator(value) : typeof mutator.get === "function" ? mutator.get(value) : value;
|
3201
|
+
}
|
3202
|
+
if (cast && operation === "get") {
|
3203
|
+
value = cast.get(value);
|
3204
|
+
}
|
3196
3205
|
let keyValue = this.$fillField(key, attr, value);
|
3197
3206
|
if (mutator && typeof mutator !== "function" && operation === "set" && mutator.set) {
|
3198
3207
|
keyValue = mutator.set(keyValue);
|
@@ -3200,36 +3209,6 @@ class Model {
|
|
3200
3209
|
if (cast && operation === "set") {
|
3201
3210
|
keyValue = cast.set(keyValue);
|
3202
3211
|
}
|
3203
|
-
if (cast || mutator) {
|
3204
|
-
Object.defineProperty(this, "_" + key, {
|
3205
|
-
configurable: true,
|
3206
|
-
writable: true,
|
3207
|
-
enumerable: false
|
3208
|
-
});
|
3209
|
-
Object.defineProperty(this, key, {
|
3210
|
-
configurable: true,
|
3211
|
-
enumerable: true,
|
3212
|
-
get() {
|
3213
|
-
let scopeValue = this["_" + key];
|
3214
|
-
if (scopeValue === void 0) {
|
3215
|
-
return keyValue;
|
3216
|
-
}
|
3217
|
-
if (operation === "set") {
|
3218
|
-
return scopeValue;
|
3219
|
-
}
|
3220
|
-
if (mutator) {
|
3221
|
-
scopeValue = typeof mutator === "function" ? mutator(scopeValue) : typeof mutator.get === "function" ? mutator.get(scopeValue) : scopeValue;
|
3222
|
-
}
|
3223
|
-
if (cast) {
|
3224
|
-
scopeValue = cast.get(scopeValue);
|
3225
|
-
}
|
3226
|
-
return scopeValue;
|
3227
|
-
},
|
3228
|
-
set(value2) {
|
3229
|
-
this["_" + key] = value2;
|
3230
|
-
}
|
3231
|
-
});
|
3232
|
-
}
|
3233
3212
|
this[key] = this[key] ?? keyValue;
|
3234
3213
|
}
|
3235
3214
|
operation === "set" && (this.$self().original[this.$getKey(this, true)] = this.$getAttributes());
|
package/dist/index.mjs
CHANGED
@@ -1447,7 +1447,8 @@ class Query {
|
|
1447
1447
|
if (isDeleting === false) {
|
1448
1448
|
notDeletableIds.push(currentModel.$getIndexId());
|
1449
1449
|
} else {
|
1450
|
-
this.hydratedDataCache.delete(this.model.$entity() + currentModel.$getIndexId());
|
1450
|
+
this.hydratedDataCache.delete("set" + this.model.$entity() + currentModel.$getIndexId());
|
1451
|
+
this.hydratedDataCache.delete("get" + this.model.$entity() + currentModel.$getIndexId());
|
1451
1452
|
afterHooks.push(() => currentModel.$self().deleted(currentModel));
|
1452
1453
|
this.checkAndDeleteRelations(currentModel);
|
1453
1454
|
}
|
@@ -1479,19 +1480,21 @@ class Query {
|
|
1479
1480
|
* an update event trigger in vue if the object is used.
|
1480
1481
|
*/
|
1481
1482
|
getHydratedModel(record, options) {
|
1482
|
-
const id = this.model.$getKey(record, true);
|
1483
|
-
const
|
1484
|
-
|
1483
|
+
const id = this.model.$entity() + this.model.$getKey(record, true);
|
1484
|
+
const operationId = options?.operation + id;
|
1485
|
+
let savedHydratedModel = this.hydratedDataCache.get(operationId);
|
1486
|
+
if (options?.action === "update") {
|
1487
|
+
this.hydratedDataCache.delete("get" + id);
|
1488
|
+
savedHydratedModel = void 0;
|
1489
|
+
}
|
1490
|
+
if (!this.getNewHydrated && savedHydratedModel) {
|
1485
1491
|
return savedHydratedModel;
|
1486
1492
|
}
|
1487
1493
|
const modelByType = this.model.$types()[record[this.model.$typeKey()]];
|
1488
1494
|
const getNewInsance = (newOptions) => (modelByType ? modelByType.newRawInstance() : this.model).$newInstance(record, { relations: false, ...options || {}, ...newOptions });
|
1489
1495
|
const hydratedModel = getNewInsance();
|
1490
|
-
if (
|
1491
|
-
this.hydratedDataCache.set(
|
1492
|
-
}
|
1493
|
-
if (id && options?.action === "update") {
|
1494
|
-
this.hydratedDataCache.set(this.model.$entity() + id, getNewInsance({ operation: "get" }));
|
1496
|
+
if (isEmpty(this.eagerLoad) && options?.operation !== "set") {
|
1497
|
+
this.hydratedDataCache.set(operationId, hydratedModel);
|
1495
1498
|
}
|
1496
1499
|
return hydratedModel;
|
1497
1500
|
}
|
@@ -3185,12 +3188,18 @@ class Model {
|
|
3185
3188
|
continue;
|
3186
3189
|
}
|
3187
3190
|
const attr = fields[key];
|
3188
|
-
|
3191
|
+
let value = attributes[key];
|
3189
3192
|
if (attr instanceof Relation && !fillRelation) {
|
3190
3193
|
continue;
|
3191
3194
|
}
|
3192
3195
|
const mutator = mutators?.[key];
|
3193
3196
|
const cast = this.$casts()[key]?.newRawInstance(fields);
|
3197
|
+
if (mutator && operation === "get") {
|
3198
|
+
value = typeof mutator === "function" ? mutator(value) : typeof mutator.get === "function" ? mutator.get(value) : value;
|
3199
|
+
}
|
3200
|
+
if (cast && operation === "get") {
|
3201
|
+
value = cast.get(value);
|
3202
|
+
}
|
3194
3203
|
let keyValue = this.$fillField(key, attr, value);
|
3195
3204
|
if (mutator && typeof mutator !== "function" && operation === "set" && mutator.set) {
|
3196
3205
|
keyValue = mutator.set(keyValue);
|
@@ -3198,36 +3207,6 @@ class Model {
|
|
3198
3207
|
if (cast && operation === "set") {
|
3199
3208
|
keyValue = cast.set(keyValue);
|
3200
3209
|
}
|
3201
|
-
if (cast || mutator) {
|
3202
|
-
Object.defineProperty(this, "_" + key, {
|
3203
|
-
configurable: true,
|
3204
|
-
writable: true,
|
3205
|
-
enumerable: false
|
3206
|
-
});
|
3207
|
-
Object.defineProperty(this, key, {
|
3208
|
-
configurable: true,
|
3209
|
-
enumerable: true,
|
3210
|
-
get() {
|
3211
|
-
let scopeValue = this["_" + key];
|
3212
|
-
if (scopeValue === void 0) {
|
3213
|
-
return keyValue;
|
3214
|
-
}
|
3215
|
-
if (operation === "set") {
|
3216
|
-
return scopeValue;
|
3217
|
-
}
|
3218
|
-
if (mutator) {
|
3219
|
-
scopeValue = typeof mutator === "function" ? mutator(scopeValue) : typeof mutator.get === "function" ? mutator.get(scopeValue) : scopeValue;
|
3220
|
-
}
|
3221
|
-
if (cast) {
|
3222
|
-
scopeValue = cast.get(scopeValue);
|
3223
|
-
}
|
3224
|
-
return scopeValue;
|
3225
|
-
},
|
3226
|
-
set(value2) {
|
3227
|
-
this["_" + key] = value2;
|
3228
|
-
}
|
3229
|
-
});
|
3230
|
-
}
|
3231
3210
|
this[key] = this[key] ?? keyValue;
|
3232
3211
|
}
|
3233
3212
|
operation === "set" && (this.$self().original[this.$getKey(this, true)] = this.$getAttributes());
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "pinia-orm-edge",
|
3
|
-
"version": "1.9.0-
|
3
|
+
"version": "1.9.0-28581943.45f87aa",
|
4
4
|
"description": "The Pinia plugin to enable Object-Relational Mapping access to the Pinia Store.",
|
5
5
|
"keywords": [
|
6
6
|
"vue",
|
@@ -46,7 +46,7 @@
|
|
46
46
|
"pinia": "^2.1.7"
|
47
47
|
},
|
48
48
|
"dependencies": {
|
49
|
-
"@pinia-orm/normalizr": "npm:@pinia-orm/normalizr-edge@1.9.0-
|
49
|
+
"@pinia-orm/normalizr": "npm:@pinia-orm/normalizr-edge@1.9.0-28581943.45f87aa"
|
50
50
|
},
|
51
51
|
"devDependencies": {
|
52
52
|
"@nuxt/eslint-config": "^0.3.10",
|