miolo-model 3.0.0-beta.165 → 3.0.0-beta.167
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/package.json +1 -1
- package/src/MioloModel.mjs +13 -1
- package/src/index.mjs +1 -1
package/package.json
CHANGED
package/src/MioloModel.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import CacheMixin from "./CacheMixin.mjs"
|
|
2
|
+
import MioloArray from "./MioloArray.mjs"
|
|
2
3
|
|
|
3
4
|
export default class MioloModel extends CacheMixin() {
|
|
4
5
|
constructor(data) {
|
|
@@ -25,7 +26,7 @@ export default class MioloModel extends CacheMixin() {
|
|
|
25
26
|
get_extra_data() {
|
|
26
27
|
const data = {}
|
|
27
28
|
for (const [key, value] of Object.entries(this)) {
|
|
28
|
-
if (value instanceof MioloModel) {
|
|
29
|
+
if (value instanceof MioloModel || value instanceof MioloArray) {
|
|
29
30
|
data[key] = value.get_data()
|
|
30
31
|
} else if (Array.isArray(value) && value.every((v) => v instanceof MioloModel)) {
|
|
31
32
|
data[key] = value.map((v) => v.get_data())
|
|
@@ -55,4 +56,15 @@ export default class MioloModel extends CacheMixin() {
|
|
|
55
56
|
...changes
|
|
56
57
|
}
|
|
57
58
|
}
|
|
59
|
+
|
|
60
|
+
merge(model) {
|
|
61
|
+
this.update(model.getData())
|
|
62
|
+
for (const [key, value] of Object.entries(model)) {
|
|
63
|
+
if (value instanceof MioloModel || value instanceof MioloArray) {
|
|
64
|
+
this[key] = value
|
|
65
|
+
} else if (Array.isArray(value) && value.every((v) => v instanceof MioloModel)) {
|
|
66
|
+
this[key] = value
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
58
70
|
}
|
package/src/index.mjs
CHANGED