spice-js 2.5.37 → 2.5.38
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/build/models/SpiceModel.js +2 -16
- package/package.json +1 -1
- package/src/models/SpiceModel.js +2 -38
|
@@ -590,9 +590,7 @@ class SpiceModel {
|
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
var db_data = form || _this6; //console.log("New Data Inside Update::::", db_data);
|
|
593
|
-
|
|
594
|
-
_this6.implementTypeFix(db_data); // console.log("After ITF::::", db_data);
|
|
595
|
-
|
|
593
|
+
// console.log("After ITF::::", db_data);
|
|
596
594
|
|
|
597
595
|
yield _this6.database.update(args.id, db_data); //console.log("Old Data Inside Update::::", results);
|
|
598
596
|
|
|
@@ -617,18 +615,6 @@ class SpiceModel {
|
|
|
617
615
|
})();
|
|
618
616
|
}
|
|
619
617
|
|
|
620
|
-
implementTypeFix(item) {
|
|
621
|
-
/* console.log("Type Before Fix", item.type, item._type);
|
|
622
|
-
let _new_type = item.type || item._type;
|
|
623
|
-
//item.type = type;
|
|
624
|
-
console.log("New type", _new_type);
|
|
625
|
-
item = { ...item, type: _new_type };
|
|
626
|
-
delete item._type; */
|
|
627
|
-
//console.log("Type After Fix", item.type, item._type);
|
|
628
|
-
//if (item._type) delete item["_type"];
|
|
629
|
-
//console.log("Type After Fix", item.type);
|
|
630
|
-
}
|
|
631
|
-
|
|
632
618
|
create(args) {
|
|
633
619
|
var _this7 = this;
|
|
634
620
|
|
|
@@ -653,7 +639,7 @@ class SpiceModel {
|
|
|
653
639
|
}
|
|
654
640
|
|
|
655
641
|
yield _this7.run_hook(workingForm, "create", "before");
|
|
656
|
-
workingForm =
|
|
642
|
+
workingForm = yield _this7.do_serialize(workingForm, "write", {}, args);
|
|
657
643
|
var results = yield _this7.database.insert(id, workingForm, args.expiry);
|
|
658
644
|
yield _this7.run_hook(_extends({}, results, {
|
|
659
645
|
id
|
package/package.json
CHANGED
package/src/models/SpiceModel.js
CHANGED
|
@@ -43,7 +43,6 @@ export default class SpiceModel {
|
|
|
43
43
|
let Database = require(`spice-${dbtype}`);
|
|
44
44
|
this.type = "";
|
|
45
45
|
this.collection = args.connection;
|
|
46
|
-
//console.log("Args -- Type::", args.type);
|
|
47
46
|
this[_args] = args.args;
|
|
48
47
|
this[_external_modifier_loaded] = false;
|
|
49
48
|
this[_disable_lifecycle_events] =
|
|
@@ -160,19 +159,6 @@ export default class SpiceModel {
|
|
|
160
159
|
}
|
|
161
160
|
// }
|
|
162
161
|
}
|
|
163
|
-
/* get type() {
|
|
164
|
-
return this._type;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Setter for 'type'
|
|
168
|
-
set type(value) {
|
|
169
|
-
if (typeof value !== "string") {
|
|
170
|
-
// example validation
|
|
171
|
-
throw new Error("Type must be a string.");
|
|
172
|
-
}
|
|
173
|
-
this._type = value;
|
|
174
|
-
//console.log("Type Setted::", value);
|
|
175
|
-
} */
|
|
176
162
|
|
|
177
163
|
get database() {
|
|
178
164
|
return this[_database];
|
|
@@ -489,9 +475,7 @@ export default class SpiceModel {
|
|
|
489
475
|
try {
|
|
490
476
|
this.updated_at = new SDate().now();
|
|
491
477
|
let results = await this.database.get(args.id);
|
|
492
|
-
console.log("Results", results);
|
|
493
478
|
let item_exist = await this.exist(results);
|
|
494
|
-
console.log("Item Exist", item_exist);
|
|
495
479
|
if (!item_exist) {
|
|
496
480
|
throw new Error(`${this.type} does not exist. in update`);
|
|
497
481
|
}
|
|
@@ -511,13 +495,8 @@ export default class SpiceModel {
|
|
|
511
495
|
form = await this.do_serialize(this, "write", cover_obj.new, args);
|
|
512
496
|
}
|
|
513
497
|
let db_data = form || this;
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
this.implementTypeFix(db_data);
|
|
517
|
-
// console.log("After ITF::::", db_data);
|
|
518
|
-
|
|
498
|
+
|
|
519
499
|
await this.database.update(args.id, db_data);
|
|
520
|
-
//console.log("Old Data Inside Update::::", results);
|
|
521
500
|
if (args.skip_hooks != true) {
|
|
522
501
|
await this.run_hook(
|
|
523
502
|
{
|
|
@@ -546,19 +525,6 @@ export default class SpiceModel {
|
|
|
546
525
|
}
|
|
547
526
|
}
|
|
548
527
|
|
|
549
|
-
implementTypeFix(item) {
|
|
550
|
-
/* console.log("Type Before Fix", item.type, item._type);
|
|
551
|
-
let _new_type = item.type || item._type;
|
|
552
|
-
//item.type = type;
|
|
553
|
-
console.log("New type", _new_type);
|
|
554
|
-
|
|
555
|
-
item = { ...item, type: _new_type };
|
|
556
|
-
delete item._type; */
|
|
557
|
-
//console.log("Type After Fix", item.type, item._type);
|
|
558
|
-
//if (item._type) delete item["_type"];
|
|
559
|
-
//console.log("Type After Fix", item.type);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
528
|
async create(args) {
|
|
563
529
|
try {
|
|
564
530
|
let form;
|
|
@@ -577,9 +543,7 @@ export default class SpiceModel {
|
|
|
577
543
|
id = args.id;
|
|
578
544
|
}
|
|
579
545
|
await this.run_hook(workingForm, "create", "before");
|
|
580
|
-
workingForm = this.
|
|
581
|
-
await this.do_serialize(workingForm, "write", {}, args)
|
|
582
|
-
);
|
|
546
|
+
workingForm = await this.do_serialize(workingForm, "write", {}, args);
|
|
583
547
|
|
|
584
548
|
let results = await this.database.insert(id, workingForm, args.expiry);
|
|
585
549
|
await this.run_hook(
|