leoric 2.13.5 → 2.13.7
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/adapters/sequelize.d.ts +5 -1
- package/dist/adapters/sequelize.js +108 -108
- package/dist/adapters/sequelize.js.map +1 -1
- package/dist/bone.js +48 -43
- package/dist/bone.js.map +1 -1
- package/dist/collection.d.ts +1 -1
- package/dist/collection.js +2 -2
- package/dist/collection.js.map +1 -1
- package/dist/constants.d.ts +14 -14
- package/dist/data_types.d.ts +1 -3
- package/dist/data_types.js +3 -1
- package/dist/data_types.js.map +1 -1
- package/dist/decorators.js.map +1 -1
- package/dist/drivers/abstract/attribute.js.map +1 -1
- package/dist/drivers/abstract/index.js +8 -8
- package/dist/drivers/abstract/index.js.map +1 -1
- package/dist/drivers/abstract/logger.js.map +1 -1
- package/dist/drivers/abstract/spellbook.d.ts +2 -2
- package/dist/drivers/abstract/spellbook.js.map +1 -1
- package/dist/drivers/index.js.map +1 -1
- package/dist/drivers/mysql/attribute.js.map +1 -1
- package/dist/drivers/mysql/data_types.d.ts +1 -1
- package/dist/drivers/mysql/data_types.js.map +1 -1
- package/dist/drivers/mysql/index.js +8 -6
- package/dist/drivers/mysql/index.js.map +1 -1
- package/dist/drivers/mysql/spellbook.js.map +1 -1
- package/dist/drivers/postgres/attribute.d.ts +1 -1
- package/dist/drivers/postgres/attribute.js.map +1 -1
- package/dist/drivers/postgres/data_types.d.ts +16 -16
- package/dist/drivers/postgres/data_types.js.map +1 -1
- package/dist/drivers/postgres/index.d.ts +1 -1
- package/dist/drivers/postgres/index.js +8 -8
- package/dist/drivers/postgres/index.js.map +1 -1
- package/dist/drivers/postgres/spellbook.js.map +1 -1
- package/dist/drivers/postgres/sqlstring.js.map +1 -1
- package/dist/drivers/sqlite/attribute.js.map +1 -1
- package/dist/drivers/sqlite/connection.js +2 -2
- package/dist/drivers/sqlite/connection.js.map +1 -1
- package/dist/drivers/sqlite/data_types.d.ts +24 -24
- package/dist/drivers/sqlite/data_types.js.map +1 -1
- package/dist/drivers/sqlite/index.js +8 -8
- package/dist/drivers/sqlite/index.js.map +1 -1
- package/dist/drivers/sqlite/pool.js +2 -2
- package/dist/drivers/sqlite/pool.js.map +1 -1
- package/dist/drivers/sqlite/spellbook.js.map +1 -1
- package/dist/drivers/sqlite/sqlstring.js +2 -2
- package/dist/drivers/sqlite/sqlstring.js.map +1 -1
- package/dist/drivers/sqljs/index.js.map +1 -1
- package/dist/drivers/sqljs/interface.d.ts +0 -2
- package/dist/drivers/sqljs/sqljs-connection.js +1 -1
- package/dist/drivers/sqljs/sqljs-connection.js.map +1 -1
- package/dist/expr.js +2 -2
- package/dist/expr.js.map +1 -1
- package/dist/expr_formatter.d.ts +1 -1
- package/dist/expr_formatter.js.map +1 -1
- package/dist/hint.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/migrations.js +8 -8
- package/dist/migrations.js.map +1 -1
- package/dist/query_object.js.map +1 -1
- package/dist/raw.js.map +1 -1
- package/dist/realm/base.js +5 -5
- package/dist/realm/base.js.map +1 -1
- package/dist/realm/index.js +2 -2
- package/dist/realm/index.js.map +1 -1
- package/dist/setup_hooks.js +13 -11
- package/dist/setup_hooks.js.map +1 -1
- package/dist/spell.js +8 -7
- package/dist/spell.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/validator.js.map +1 -1
- package/lib/adapters/sequelize.d.ts +5 -1
- package/lib/adapters/sequelize.js.map +1 -1
- package/lib/bone.js +6 -1
- package/lib/bone.js.map +1 -1
- package/lib/browser.js.map +1 -1
- package/lib/collection.d.ts +1 -1
- package/lib/collection.js.map +1 -1
- package/lib/constants.d.ts +14 -14
- package/lib/data_types.d.ts +1 -3
- package/lib/data_types.js +4 -2
- package/lib/data_types.js.map +1 -1
- package/lib/decorators.js +4 -5
- package/lib/decorators.js.map +1 -1
- package/lib/drivers/abstract/attribute.js.map +1 -1
- package/lib/drivers/abstract/index.js.map +1 -1
- package/lib/drivers/abstract/logger.js.map +1 -1
- package/lib/drivers/abstract/spellbook.d.ts +2 -2
- package/lib/drivers/abstract/spellbook.js.map +1 -1
- package/lib/drivers/index.js.map +1 -1
- package/lib/drivers/mysql/attribute.js.map +1 -1
- package/lib/drivers/mysql/data_types.d.ts +1 -1
- package/lib/drivers/mysql/index.js +3 -1
- package/lib/drivers/mysql/index.js.map +1 -1
- package/lib/drivers/mysql/spellbook.js.map +1 -1
- package/lib/drivers/postgres/attribute.d.ts +1 -1
- package/lib/drivers/postgres/attribute.js.map +1 -1
- package/lib/drivers/postgres/data_types.d.ts +16 -16
- package/lib/drivers/postgres/index.d.ts +1 -1
- package/lib/drivers/postgres/index.js.map +1 -1
- package/lib/drivers/postgres/sqlstring.js.map +1 -1
- package/lib/drivers/sqlite/attribute.js.map +1 -1
- package/lib/drivers/sqlite/connection.js.map +1 -1
- package/lib/drivers/sqlite/data_types.d.ts +24 -24
- package/lib/drivers/sqlite/data_types.js.map +1 -1
- package/lib/drivers/sqlite/index.js.map +1 -1
- package/lib/drivers/sqlite/pool.js.map +1 -1
- package/lib/drivers/sqlite/spellbook.js.map +1 -1
- package/lib/drivers/sqlite/sqlstring.js.map +1 -1
- package/lib/drivers/sqljs/index.js.map +1 -1
- package/lib/drivers/sqljs/interface.d.ts +0 -2
- package/lib/drivers/sqljs/sqljs-connection.js +17 -7
- package/lib/drivers/sqljs/sqljs-connection.js.map +1 -1
- package/lib/expr.js +2 -2
- package/lib/expr.js.map +1 -1
- package/lib/expr_formatter.d.ts +1 -1
- package/lib/expr_formatter.js.map +1 -1
- package/lib/hint.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/migrations.js.map +1 -1
- package/lib/query_object.js.map +1 -1
- package/lib/raw.js.map +1 -1
- package/lib/realm/base.js.map +1 -1
- package/lib/realm/index.js.map +1 -1
- package/lib/setup_hooks.js.map +1 -1
- package/lib/spell.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/validator.js.map +1 -1
- package/package.json +5 -5
|
@@ -28,6 +28,10 @@ interface SequelizeInstanceUpdateOptions<T extends SequelizeBone> extends QueryO
|
|
|
28
28
|
fields?: Array<[keyof Extract<CommonValues<T>, Literal>] | string | Raw> | [keyof Extract<CommonValues<T>, Literal>];
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
interface CountSequelizeOptions<T extends typeof SequelizeBone> extends BaseSequelizeConditions<T> {
|
|
32
|
+
col?: BoneColumns<T> | Raw | '*';
|
|
33
|
+
}
|
|
34
|
+
|
|
31
35
|
interface SequelizeConditions<T extends typeof SequelizeBone> extends BaseSequelizeConditions<T> {
|
|
32
36
|
group?: BoneColumns<T> | BoneColumns<T>[] | Raw | string;
|
|
33
37
|
having?: WhereConditions<T> | string | { [key:string]: Literal | Literal[] } | Raw;
|
|
@@ -117,7 +121,7 @@ export class SequelizeBone extends AbstractBone {
|
|
|
117
121
|
*/
|
|
118
122
|
static bulkBuild<T extends typeof SequelizeBone>(this:T, valueSets: Array<BoneCreateValues<T>>, options?: BoneOptions): Array<InstanceType<T>>;
|
|
119
123
|
|
|
120
|
-
static count<T extends typeof SequelizeBone>(this: T, conditions?:
|
|
124
|
+
static count<T extends typeof SequelizeBone>(this: T, conditions?: CountSequelizeOptions<T>): Spell<T, ResultSet<T> | number>;
|
|
121
125
|
static count<T extends typeof SequelizeBone>(this: T, name?: BoneColumns<T>): Spell<T, ResultSet<T> | number>;
|
|
122
126
|
static count<T extends typeof SequelizeBone>(this: T, name?: Raw | '*'): Spell<T, ResultSet<T> | number>;
|
|
123
127
|
|
|
@@ -35,8 +35,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
37
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
-
return g =
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
39
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
40
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
41
|
function step(op) {
|
|
42
42
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -359,14 +359,14 @@ module.exports = function sequelize(Bone) {
|
|
|
359
359
|
* @param {function|object|array} name
|
|
360
360
|
*/
|
|
361
361
|
Spine.setScope = function (name) {
|
|
362
|
-
var
|
|
362
|
+
var _b;
|
|
363
363
|
var args = [];
|
|
364
364
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
365
365
|
args[_i - 1] = arguments[_i];
|
|
366
366
|
}
|
|
367
367
|
if (name && this._scopes[name]) {
|
|
368
368
|
if (this._scopes[name].__isFunc) {
|
|
369
|
-
this._scope = parseScope((
|
|
369
|
+
this._scope = parseScope((_b = this._scopes[name]).call.apply(_b, __spreadArray([this], __read(args), false)));
|
|
370
370
|
}
|
|
371
371
|
else {
|
|
372
372
|
this._scope = this._scopes[name];
|
|
@@ -385,7 +385,7 @@ module.exports = function sequelize(Bone) {
|
|
|
385
385
|
if (descriptors === void 0) { descriptors = {}; }
|
|
386
386
|
_super.init.call(this, attributes, opts, descriptors);
|
|
387
387
|
// sequelize opts.getterMethods | setterMethods
|
|
388
|
-
var
|
|
388
|
+
var _b = opts.getterMethods, getterMethods = _b === void 0 ? {} : _b, _c = opts.setterMethods, setterMethods = _c === void 0 ? {} : _c, defaultScope = opts.defaultScope, scopes = opts.scopes;
|
|
389
389
|
var setProp = function (obj, type) { return function (result) {
|
|
390
390
|
Object.keys(obj).map(function (key) {
|
|
391
391
|
if (!result[key]) {
|
|
@@ -478,7 +478,7 @@ module.exports = function sequelize(Bone) {
|
|
|
478
478
|
// EXISTS
|
|
479
479
|
// static async create(props) {}
|
|
480
480
|
Spine.decrement = function (fields, options) {
|
|
481
|
-
var e_4,
|
|
481
|
+
var e_4, _b;
|
|
482
482
|
var where = options.where, paranoid = options.paranoid;
|
|
483
483
|
var spell = _super.update.call(this, where, {}, options);
|
|
484
484
|
if (Array.isArray(fields)) {
|
|
@@ -491,7 +491,7 @@ module.exports = function sequelize(Bone) {
|
|
|
491
491
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
492
492
|
finally {
|
|
493
493
|
try {
|
|
494
|
-
if (fields_1_1 && !fields_1_1.done && (
|
|
494
|
+
if (fields_1_1 && !fields_1_1.done && (_b = fields_1.return)) _b.call(fields_1);
|
|
495
495
|
}
|
|
496
496
|
finally { if (e_4) throw e_4.error; }
|
|
497
497
|
}
|
|
@@ -512,12 +512,12 @@ module.exports = function sequelize(Bone) {
|
|
|
512
512
|
};
|
|
513
513
|
// EXISTS
|
|
514
514
|
// static async describe() {}
|
|
515
|
-
Spine.destroy = function (
|
|
516
|
-
|
|
517
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
515
|
+
Spine.destroy = function () {
|
|
516
|
+
return __awaiter(this, arguments, void 0, function (options) {
|
|
518
517
|
var where, individualHooks, paranoid, findSpell, instances;
|
|
519
|
-
|
|
520
|
-
|
|
518
|
+
if (options === void 0) { options = {}; }
|
|
519
|
+
return __generator(this, function (_b) {
|
|
520
|
+
switch (_b.label) {
|
|
521
521
|
case 0:
|
|
522
522
|
where = options.where, individualHooks = options.individualHooks, paranoid = options.paranoid;
|
|
523
523
|
if (!individualHooks) return [3 /*break*/, 4];
|
|
@@ -526,13 +526,13 @@ module.exports = function sequelize(Bone) {
|
|
|
526
526
|
findSpell = findSpell.unparanoid;
|
|
527
527
|
return [4 /*yield*/, findSpell];
|
|
528
528
|
case 1:
|
|
529
|
-
instances =
|
|
529
|
+
instances = _b.sent();
|
|
530
530
|
if (!instances.length) return [3 /*break*/, 3];
|
|
531
531
|
return [4 /*yield*/, Promise.all(instances.map(function (instance) { return instance.destroy(options); }))];
|
|
532
|
-
case 2: return [2 /*return*/,
|
|
532
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
533
533
|
case 3: return [3 /*break*/, 6];
|
|
534
534
|
case 4: return [4 /*yield*/, this.bulkDestroy(options)];
|
|
535
|
-
case 5: return [2 /*return*/,
|
|
535
|
+
case 5: return [2 /*return*/, _b.sent()];
|
|
536
536
|
case 6: return [2 /*return*/];
|
|
537
537
|
}
|
|
538
538
|
});
|
|
@@ -562,12 +562,12 @@ module.exports = function sequelize(Bone) {
|
|
|
562
562
|
if (options === void 0) { options = {}; }
|
|
563
563
|
return this.findOne(options);
|
|
564
564
|
};
|
|
565
|
-
Spine.findAndCountAll = function (
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
return __generator(this, function (
|
|
570
|
-
switch (
|
|
565
|
+
Spine.findAndCountAll = function () {
|
|
566
|
+
return __awaiter(this, arguments, void 0, function (options) {
|
|
567
|
+
var spell, spellCount, _b, rows, count;
|
|
568
|
+
if (options === void 0) { options = {}; }
|
|
569
|
+
return __generator(this, function (_c) {
|
|
570
|
+
switch (_c.label) {
|
|
571
571
|
case 0:
|
|
572
572
|
spell = this._find({}, filterOptions(options));
|
|
573
573
|
translateOptions(spell, options);
|
|
@@ -582,45 +582,45 @@ module.exports = function sequelize(Bone) {
|
|
|
582
582
|
}
|
|
583
583
|
return [4 /*yield*/, Promise.all([spell, spellCount.count()])];
|
|
584
584
|
case 1:
|
|
585
|
-
|
|
585
|
+
_b = __read.apply(void 0, [_c.sent(), 2]), rows = _b[0], count = _b[1];
|
|
586
586
|
return [2 /*return*/, { rows: rows, count: count }];
|
|
587
587
|
}
|
|
588
588
|
});
|
|
589
589
|
});
|
|
590
590
|
};
|
|
591
591
|
Spine.findByPk = function (value, options) {
|
|
592
|
-
var
|
|
592
|
+
var _b;
|
|
593
593
|
if (options === void 0) { options = {}; }
|
|
594
|
-
var spell = _super.findOne.call(this, (
|
|
594
|
+
var spell = _super.findOne.call(this, (_b = {}, _b[this.primaryKey] = value, _b), options);
|
|
595
595
|
translateOptions(spell, options);
|
|
596
596
|
if (options.paranoid === false)
|
|
597
597
|
spell = spell.unparanoid;
|
|
598
598
|
return spell;
|
|
599
599
|
};
|
|
600
|
-
Spine.findCreateFind = function (
|
|
601
|
-
|
|
602
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
600
|
+
Spine.findCreateFind = function () {
|
|
601
|
+
return __awaiter(this, arguments, void 0, function (options) {
|
|
603
602
|
var where, defaults, instance, err_1;
|
|
604
|
-
|
|
605
|
-
|
|
603
|
+
if (options === void 0) { options = {}; }
|
|
604
|
+
return __generator(this, function (_b) {
|
|
605
|
+
switch (_b.label) {
|
|
606
606
|
case 0:
|
|
607
607
|
where = options.where, defaults = options.defaults;
|
|
608
608
|
return [4 /*yield*/, this.findOne(options)];
|
|
609
609
|
case 1:
|
|
610
|
-
instance =
|
|
610
|
+
instance = _b.sent();
|
|
611
611
|
if (!!instance) return [3 /*break*/, 6];
|
|
612
|
-
|
|
612
|
+
_b.label = 2;
|
|
613
613
|
case 2:
|
|
614
|
-
|
|
614
|
+
_b.trys.push([2, 4, , 6]);
|
|
615
615
|
return [4 /*yield*/, this.create(__assign(__assign({}, defaults), where), options)];
|
|
616
616
|
case 3:
|
|
617
|
-
instance =
|
|
617
|
+
instance = _b.sent();
|
|
618
618
|
return [3 /*break*/, 6];
|
|
619
619
|
case 4:
|
|
620
|
-
err_1 =
|
|
620
|
+
err_1 = _b.sent();
|
|
621
621
|
return [4 /*yield*/, this.findOne(options)];
|
|
622
622
|
case 5:
|
|
623
|
-
instance =
|
|
623
|
+
instance = _b.sent();
|
|
624
624
|
return [3 /*break*/, 6];
|
|
625
625
|
case 6: return [2 /*return*/, instance];
|
|
626
626
|
}
|
|
@@ -648,17 +648,17 @@ module.exports = function sequelize(Bone) {
|
|
|
648
648
|
return spell.unparanoid;
|
|
649
649
|
return spell;
|
|
650
650
|
};
|
|
651
|
-
Spine.findOrBuild = function (
|
|
652
|
-
|
|
653
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
651
|
+
Spine.findOrBuild = function () {
|
|
652
|
+
return __awaiter(this, arguments, void 0, function (options) {
|
|
654
653
|
var where, defaults, validate, instance, result;
|
|
655
|
-
|
|
656
|
-
|
|
654
|
+
if (options === void 0) { options = {}; }
|
|
655
|
+
return __generator(this, function (_b) {
|
|
656
|
+
switch (_b.label) {
|
|
657
657
|
case 0:
|
|
658
658
|
where = options.where, defaults = options.defaults, validate = options.validate;
|
|
659
659
|
return [4 /*yield*/, this.findOne(options)];
|
|
660
660
|
case 1:
|
|
661
|
-
instance =
|
|
661
|
+
instance = _b.sent();
|
|
662
662
|
result = instance || this.build(__assign(__assign({}, defaults), where), { validate: validate });
|
|
663
663
|
return [2 /*return*/, [result, !instance]];
|
|
664
664
|
}
|
|
@@ -667,17 +667,17 @@ module.exports = function sequelize(Bone) {
|
|
|
667
667
|
};
|
|
668
668
|
Spine.findOrCreate = function (options) {
|
|
669
669
|
return __awaiter(this, void 0, void 0, function () {
|
|
670
|
-
var
|
|
671
|
-
return __generator(this, function (
|
|
672
|
-
switch (
|
|
670
|
+
var _b, result, built;
|
|
671
|
+
return __generator(this, function (_c) {
|
|
672
|
+
switch (_c.label) {
|
|
673
673
|
case 0: return [4 /*yield*/, this.findOrBuild(options)];
|
|
674
674
|
case 1:
|
|
675
|
-
|
|
675
|
+
_b = __read.apply(void 0, [_c.sent(), 2]), result = _b[0], built = _b[1];
|
|
676
676
|
if (!built) return [3 /*break*/, 3];
|
|
677
677
|
return [4 /*yield*/, result.save()];
|
|
678
678
|
case 2:
|
|
679
|
-
|
|
680
|
-
|
|
679
|
+
_c.sent();
|
|
680
|
+
_c.label = 3;
|
|
681
681
|
case 3: return [2 /*return*/, [result, built]];
|
|
682
682
|
}
|
|
683
683
|
});
|
|
@@ -691,7 +691,7 @@ module.exports = function sequelize(Bone) {
|
|
|
691
691
|
// BREAKING
|
|
692
692
|
// static hasOne() {}
|
|
693
693
|
Spine.increment = function (fields, options) {
|
|
694
|
-
var e_5,
|
|
694
|
+
var e_5, _b;
|
|
695
695
|
if (options === void 0) { options = {}; }
|
|
696
696
|
var where = options.where, paranoid = options.paranoid;
|
|
697
697
|
// pass options to update
|
|
@@ -706,7 +706,7 @@ module.exports = function sequelize(Bone) {
|
|
|
706
706
|
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
707
707
|
finally {
|
|
708
708
|
try {
|
|
709
|
-
if (fields_2_1 && !fields_2_1.done && (
|
|
709
|
+
if (fields_2_1 && !fields_2_1.done && (_b = fields_2.return)) _b.call(fields_2);
|
|
710
710
|
}
|
|
711
711
|
finally { if (e_5) throw e_5.error; }
|
|
712
712
|
}
|
|
@@ -725,40 +725,40 @@ module.exports = function sequelize(Bone) {
|
|
|
725
725
|
return spell.unparanoid;
|
|
726
726
|
return spell;
|
|
727
727
|
};
|
|
728
|
-
Spine.max = function (
|
|
729
|
-
|
|
730
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
728
|
+
Spine.max = function (attribute_1) {
|
|
729
|
+
return __awaiter(this, arguments, void 0, function (attribute, options) {
|
|
731
730
|
var spell;
|
|
732
|
-
|
|
733
|
-
|
|
731
|
+
if (options === void 0) { options = {}; }
|
|
732
|
+
return __generator(this, function (_b) {
|
|
733
|
+
switch (_b.label) {
|
|
734
734
|
case 0:
|
|
735
735
|
spell = _super._find.call(this, options.where, filterOptions(options)).$maximum(attribute);
|
|
736
736
|
if (options.paranoid === false)
|
|
737
737
|
spell = spell.unparanoid;
|
|
738
738
|
return [4 /*yield*/, spell];
|
|
739
|
-
case 1: return [2 /*return*/,
|
|
739
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
740
740
|
}
|
|
741
741
|
});
|
|
742
742
|
});
|
|
743
743
|
};
|
|
744
|
-
Spine.min = function (
|
|
745
|
-
|
|
746
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
744
|
+
Spine.min = function (attribute_1) {
|
|
745
|
+
return __awaiter(this, arguments, void 0, function (attribute, options) {
|
|
747
746
|
var spell;
|
|
748
|
-
|
|
749
|
-
|
|
747
|
+
if (options === void 0) { options = {}; }
|
|
748
|
+
return __generator(this, function (_b) {
|
|
749
|
+
switch (_b.label) {
|
|
750
750
|
case 0:
|
|
751
751
|
spell = _super._find.call(this, options.where, filterOptions(options)).$minimum(attribute);
|
|
752
752
|
if (options.paranoid === false)
|
|
753
753
|
spell = spell.unparanoid;
|
|
754
754
|
return [4 /*yield*/, spell];
|
|
755
|
-
case 1: return [2 /*return*/,
|
|
755
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
756
756
|
}
|
|
757
757
|
});
|
|
758
758
|
});
|
|
759
759
|
};
|
|
760
760
|
Spine.removeAttribute = function (name) {
|
|
761
|
-
var
|
|
761
|
+
var _b = this, attributes = _b.attributes, attributeMap = _b.attributeMap;
|
|
762
762
|
var columnInfo = attributes[name];
|
|
763
763
|
delete attributes[name];
|
|
764
764
|
delete attributeMap[columnInfo.columnName];
|
|
@@ -770,18 +770,18 @@ module.exports = function sequelize(Bone) {
|
|
|
770
770
|
Spine.schema = function () {
|
|
771
771
|
throw new Error('unimplemented');
|
|
772
772
|
};
|
|
773
|
-
Spine.sum = function (
|
|
774
|
-
|
|
775
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
773
|
+
Spine.sum = function (attribute_1) {
|
|
774
|
+
return __awaiter(this, arguments, void 0, function (attribute, options) {
|
|
776
775
|
var spell;
|
|
777
|
-
|
|
778
|
-
|
|
776
|
+
if (options === void 0) { options = {}; }
|
|
777
|
+
return __generator(this, function (_b) {
|
|
778
|
+
switch (_b.label) {
|
|
779
779
|
case 0:
|
|
780
780
|
spell = _super.find.call(this, options.where, filterOptions(options)).$sum(attribute);
|
|
781
781
|
if (options.paranoid === false)
|
|
782
782
|
spell = spell.unparanoid;
|
|
783
783
|
return [4 /*yield*/, spell];
|
|
784
|
-
case 1: return [2 /*return*/,
|
|
784
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
785
785
|
}
|
|
786
786
|
});
|
|
787
787
|
});
|
|
@@ -790,12 +790,12 @@ module.exports = function sequelize(Bone) {
|
|
|
790
790
|
// static async sync() {}
|
|
791
791
|
// EXISTS
|
|
792
792
|
// static async truncate() {}
|
|
793
|
-
Spine.update = function (
|
|
794
|
-
|
|
795
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
793
|
+
Spine.update = function (values_1) {
|
|
794
|
+
return __awaiter(this, arguments, void 0, function (values, options) {
|
|
796
795
|
var where, paranoid, individualHooks, findSpell, instances;
|
|
797
|
-
|
|
798
|
-
|
|
796
|
+
if (options === void 0) { options = {}; }
|
|
797
|
+
return __generator(this, function (_b) {
|
|
798
|
+
switch (_b.label) {
|
|
799
799
|
case 0:
|
|
800
800
|
where = options.where, paranoid = options.paranoid, individualHooks = options.individualHooks;
|
|
801
801
|
if (!individualHooks) return [3 /*break*/, 4];
|
|
@@ -805,10 +805,10 @@ module.exports = function sequelize(Bone) {
|
|
|
805
805
|
findSpell = findSpell.unparanoid;
|
|
806
806
|
return [4 /*yield*/, findSpell];
|
|
807
807
|
case 1:
|
|
808
|
-
instances =
|
|
808
|
+
instances = _b.sent();
|
|
809
809
|
if (!instances.length) return [3 /*break*/, 3];
|
|
810
810
|
return [4 /*yield*/, Promise.all(instances.map(function (instance) { return instance.update(values, options); }))];
|
|
811
|
-
case 2: return [2 /*return*/,
|
|
811
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
812
812
|
case 3: return [3 /*break*/, 5];
|
|
813
813
|
case 4: return [2 /*return*/, this.bulkUpdate(values, options)];
|
|
814
814
|
case 5: return [2 /*return*/];
|
|
@@ -819,7 +819,7 @@ module.exports = function sequelize(Bone) {
|
|
|
819
819
|
// proxy to class.update({ individualHooks=false }) see https://github.com/sequelize/sequelize/blob/4063c2ab627ad57919d5b45cc7755f077a69fa5e/lib/model.js#L3083 before(after)BulkUpdate
|
|
820
820
|
Spine.bulkUpdate = function (values, options) {
|
|
821
821
|
if (options === void 0) { options = {}; }
|
|
822
|
-
var where = options.where,
|
|
822
|
+
var where = options.where, _b = options.paranoid, paranoid = _b === void 0 ? false : _b, validate = options.validate;
|
|
823
823
|
var whereConditions = where || {};
|
|
824
824
|
var spell = _super.update.call(this, whereConditions, values, __assign({ validate: validate, hooks: false }, options));
|
|
825
825
|
var transOptions = __assign({}, options);
|
|
@@ -833,17 +833,17 @@ module.exports = function sequelize(Bone) {
|
|
|
833
833
|
// static upsert(values, options)
|
|
834
834
|
// EXISTS
|
|
835
835
|
// get isNewRecord() {}
|
|
836
|
-
Spine.prototype.update = function (
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
var _a, fields, changeValues, originalValues, name, changedKeys, changedKeys_1, changedKeys_1_1, name, changes, res, err_2;
|
|
841
|
-
var e_6, _b;
|
|
836
|
+
Spine.prototype.update = function () {
|
|
837
|
+
return __awaiter(this, arguments, void 0, function (values, options) {
|
|
838
|
+
var _b, fields, changeValues, originalValues, name, changedKeys, changedKeys_1, changedKeys_1_1, name, changes, res, err_2;
|
|
839
|
+
var e_6, _c;
|
|
842
840
|
var _this = this;
|
|
843
|
-
|
|
844
|
-
|
|
841
|
+
if (values === void 0) { values = {}; }
|
|
842
|
+
if (options === void 0) { options = {}; }
|
|
843
|
+
return __generator(this, function (_d) {
|
|
844
|
+
switch (_d.label) {
|
|
845
845
|
case 0:
|
|
846
|
-
|
|
846
|
+
_b = options.fields, fields = _b === void 0 ? [] : _b;
|
|
847
847
|
changeValues = {};
|
|
848
848
|
originalValues = Object.assign({}, this.getRaw());
|
|
849
849
|
for (name in values) {
|
|
@@ -866,7 +866,7 @@ module.exports = function sequelize(Bone) {
|
|
|
866
866
|
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
867
867
|
finally {
|
|
868
868
|
try {
|
|
869
|
-
if (changedKeys_1_1 && !changedKeys_1_1.done && (
|
|
869
|
+
if (changedKeys_1_1 && !changedKeys_1_1.done && (_c = changedKeys_1.return)) _c.call(changedKeys_1);
|
|
870
870
|
}
|
|
871
871
|
finally { if (e_6) throw e_6.error; }
|
|
872
872
|
}
|
|
@@ -887,15 +887,15 @@ module.exports = function sequelize(Bone) {
|
|
|
887
887
|
}
|
|
888
888
|
// instance update don't need to be paranoid
|
|
889
889
|
options.paranoid = false;
|
|
890
|
-
|
|
890
|
+
_d.label = 1;
|
|
891
891
|
case 1:
|
|
892
|
-
|
|
892
|
+
_d.trys.push([1, 3, , 4]);
|
|
893
893
|
return [4 /*yield*/, _super.prototype._update.call(this, changes, options)];
|
|
894
894
|
case 2:
|
|
895
|
-
res =
|
|
895
|
+
res = _d.sent();
|
|
896
896
|
return [2 /*return*/, res];
|
|
897
897
|
case 3:
|
|
898
|
-
err_2 =
|
|
898
|
+
err_2 = _d.sent();
|
|
899
899
|
// revert value in case update failed
|
|
900
900
|
this._setRaw(originalValues);
|
|
901
901
|
throw err_2;
|
|
@@ -907,7 +907,7 @@ module.exports = function sequelize(Bone) {
|
|
|
907
907
|
// EXISTS
|
|
908
908
|
// get isNewRecord() {}
|
|
909
909
|
Spine.prototype.decrement = function (fields, options) {
|
|
910
|
-
var e_7,
|
|
910
|
+
var e_7, _b, _c;
|
|
911
911
|
if (options === void 0) { options = {}; }
|
|
912
912
|
var Model = this.constructor;
|
|
913
913
|
var primaryKey = Model.primaryKey;
|
|
@@ -929,7 +929,7 @@ module.exports = function sequelize(Bone) {
|
|
|
929
929
|
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
930
930
|
finally {
|
|
931
931
|
try {
|
|
932
|
-
if (fields_3_1 && !fields_3_1.done && (
|
|
932
|
+
if (fields_3_1 && !fields_3_1.done && (_b = fields_3.return)) _b.call(fields_3);
|
|
933
933
|
}
|
|
934
934
|
finally { if (e_7) throw e_7.error; }
|
|
935
935
|
}
|
|
@@ -951,7 +951,7 @@ module.exports = function sequelize(Bone) {
|
|
|
951
951
|
}
|
|
952
952
|
this._validateAttributes(updateValues);
|
|
953
953
|
}
|
|
954
|
-
return Model.decrement(fields, __assign(__assign({}, options), { where: (
|
|
954
|
+
return Model.decrement(fields, __assign(__assign({}, options), { where: (_c = {}, _c[primaryKey] = this[primaryKey], _c) }));
|
|
955
955
|
};
|
|
956
956
|
/**
|
|
957
957
|
*
|
|
@@ -959,15 +959,15 @@ module.exports = function sequelize(Bone) {
|
|
|
959
959
|
* @param {*} [options={}]
|
|
960
960
|
* @returns
|
|
961
961
|
*/
|
|
962
|
-
Spine.prototype.destroy = function (
|
|
963
|
-
|
|
964
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
962
|
+
Spine.prototype.destroy = function () {
|
|
963
|
+
return __awaiter(this, arguments, void 0, function (options) {
|
|
965
964
|
var removeResult;
|
|
966
|
-
|
|
967
|
-
|
|
965
|
+
if (options === void 0) { options = {}; }
|
|
966
|
+
return __generator(this, function (_b) {
|
|
967
|
+
switch (_b.label) {
|
|
968
968
|
case 0: return [4 /*yield*/, this._remove(options.force, __assign({}, options))];
|
|
969
969
|
case 1:
|
|
970
|
-
removeResult =
|
|
970
|
+
removeResult = _b.sent();
|
|
971
971
|
if (options.force)
|
|
972
972
|
return [2 /*return*/, removeResult];
|
|
973
973
|
return [2 /*return*/, this];
|
|
@@ -998,7 +998,7 @@ module.exports = function sequelize(Bone) {
|
|
|
998
998
|
configurable: true
|
|
999
999
|
});
|
|
1000
1000
|
Spine.prototype.increment = function (fields, options) {
|
|
1001
|
-
var e_8,
|
|
1001
|
+
var e_8, _b, _c;
|
|
1002
1002
|
if (options === void 0) { options = {}; }
|
|
1003
1003
|
var Model = this.constructor;
|
|
1004
1004
|
var primaryKey = Model.primaryKey;
|
|
@@ -1020,7 +1020,7 @@ module.exports = function sequelize(Bone) {
|
|
|
1020
1020
|
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
1021
1021
|
finally {
|
|
1022
1022
|
try {
|
|
1023
|
-
if (fields_4_1 && !fields_4_1.done && (
|
|
1023
|
+
if (fields_4_1 && !fields_4_1.done && (_b = fields_4.return)) _b.call(fields_4);
|
|
1024
1024
|
}
|
|
1025
1025
|
finally { if (e_8) throw e_8.error; }
|
|
1026
1026
|
}
|
|
@@ -1042,20 +1042,20 @@ module.exports = function sequelize(Bone) {
|
|
|
1042
1042
|
}
|
|
1043
1043
|
this._validateAttributes(updateValues);
|
|
1044
1044
|
}
|
|
1045
|
-
return Model.increment(fields, __assign(__assign({}, options), { where: (
|
|
1045
|
+
return Model.increment(fields, __assign(__assign({}, options), { where: (_c = {}, _c[primaryKey] = this[primaryKey], _c) }));
|
|
1046
1046
|
};
|
|
1047
1047
|
Spine.prototype.isSoftDeleted = function () {
|
|
1048
1048
|
var deletedAt = this.constructor.timestamps.deletedAt;
|
|
1049
1049
|
return this[deletedAt] != null;
|
|
1050
1050
|
};
|
|
1051
1051
|
Spine.prototype.previous = function (key) {
|
|
1052
|
-
var e_9,
|
|
1052
|
+
var e_9, _b;
|
|
1053
1053
|
if (key != null)
|
|
1054
1054
|
return this.getRawPrevious(key);
|
|
1055
1055
|
var result = {};
|
|
1056
1056
|
try {
|
|
1057
|
-
for (var
|
|
1058
|
-
var attrKey =
|
|
1057
|
+
for (var _c = __values(Object.keys(this.constructor.attributes)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1058
|
+
var attrKey = _d.value;
|
|
1059
1059
|
var prevValue = this.getRawPrevious(attrKey);
|
|
1060
1060
|
if (prevValue !== undefined)
|
|
1061
1061
|
result[attrKey] = prevValue;
|
|
@@ -1064,7 +1064,7 @@ module.exports = function sequelize(Bone) {
|
|
|
1064
1064
|
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
1065
1065
|
finally {
|
|
1066
1066
|
try {
|
|
1067
|
-
if (
|
|
1067
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
1068
1068
|
}
|
|
1069
1069
|
finally { if (e_9) throw e_9.error; }
|
|
1070
1070
|
}
|
|
@@ -1090,9 +1090,9 @@ module.exports = function sequelize(Bone) {
|
|
|
1090
1090
|
// EXISTS
|
|
1091
1091
|
// validate() {}
|
|
1092
1092
|
Spine.prototype.where = function () {
|
|
1093
|
-
var
|
|
1093
|
+
var _b;
|
|
1094
1094
|
var primaryKey = this.constructor.primaryKey;
|
|
1095
|
-
return
|
|
1095
|
+
return _b = {}, _b[primaryKey] = this[primaryKey], _b;
|
|
1096
1096
|
};
|
|
1097
1097
|
Object.defineProperty(Spine.prototype, "Model", {
|
|
1098
1098
|
/**
|