query-core 0.6.2 → 0.6.3
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/lib/services.js +5 -5
- package/package.json +1 -1
- package/src/services.ts +5 -5
package/lib/services.js
CHANGED
|
@@ -524,7 +524,7 @@ var CRUDRepository = (function (_super) {
|
|
|
524
524
|
return db.exec(stmt.query, stmt.params);
|
|
525
525
|
}
|
|
526
526
|
else {
|
|
527
|
-
|
|
527
|
+
throw new Error("cannot build delete query by id");
|
|
528
528
|
}
|
|
529
529
|
};
|
|
530
530
|
return CRUDRepository;
|
|
@@ -610,7 +610,7 @@ var SqlRepository = (function (_super) {
|
|
|
610
610
|
};
|
|
611
611
|
SqlRepository.prototype.load = function (id, ctx) {
|
|
612
612
|
var stmt = build_1.select(id, this.table, this.primaryKeys, this.param);
|
|
613
|
-
if (!stmt) {
|
|
613
|
+
if (!stmt.query) {
|
|
614
614
|
throw new Error("cannot build query by id");
|
|
615
615
|
}
|
|
616
616
|
var fn = this.fromDB;
|
|
@@ -633,7 +633,7 @@ var SqlRepository = (function (_super) {
|
|
|
633
633
|
SqlRepository.prototype.exist = function (id, ctx) {
|
|
634
634
|
var field = this.primaryKeys[0].column ? this.primaryKeys[0].column : this.primaryKeys[0].name;
|
|
635
635
|
var stmt = build_1.exist(id, this.table, this.primaryKeys, this.param, field);
|
|
636
|
-
if (!stmt) {
|
|
636
|
+
if (!stmt.query) {
|
|
637
637
|
throw new Error("cannot build query by id");
|
|
638
638
|
}
|
|
639
639
|
var db = ctx ? ctx : this.db;
|
|
@@ -646,7 +646,7 @@ var SqlRepository = (function (_super) {
|
|
|
646
646
|
return db.exec(stmt.query, stmt.params);
|
|
647
647
|
}
|
|
648
648
|
else {
|
|
649
|
-
|
|
649
|
+
throw new Error("cannot build delete query by id");
|
|
650
650
|
}
|
|
651
651
|
};
|
|
652
652
|
return SqlRepository;
|
|
@@ -699,7 +699,7 @@ var Query = (function (_super) {
|
|
|
699
699
|
Query.prototype.exist = function (id, ctx) {
|
|
700
700
|
var field = this.primaryKeys[0].column ? this.primaryKeys[0].column : this.primaryKeys[0].name;
|
|
701
701
|
var stmt = build_1.exist(id, this.table, this.primaryKeys, this.param, field);
|
|
702
|
-
if (stmt.query) {
|
|
702
|
+
if (!stmt.query) {
|
|
703
703
|
throw new Error("cannot build query by id");
|
|
704
704
|
}
|
|
705
705
|
return this.query(stmt.query, stmt.params, undefined, undefined, ctx).then(function (res) { return (!res || res.length === 0 ? false : true); });
|
package/package.json
CHANGED
package/src/services.ts
CHANGED
|
@@ -574,7 +574,7 @@ export class CRUDRepository<T, ID> extends SqlWriter<T> {
|
|
|
574
574
|
const db = ctx ? ctx : this.db
|
|
575
575
|
return db.exec(stmt.query, stmt.params)
|
|
576
576
|
} else {
|
|
577
|
-
|
|
577
|
+
throw new Error("cannot build delete query by id")
|
|
578
578
|
}
|
|
579
579
|
}
|
|
580
580
|
}
|
|
@@ -695,7 +695,7 @@ export class SqlRepository<T, ID, S> extends SqlSearchWriter<T, S> {
|
|
|
695
695
|
}
|
|
696
696
|
load(id: ID, ctx?: Transaction): Promise<T | null> {
|
|
697
697
|
const stmt = select<ID>(id, this.table, this.primaryKeys, this.param)
|
|
698
|
-
if (!stmt) {
|
|
698
|
+
if (!stmt.query) {
|
|
699
699
|
throw new Error("cannot build query by id")
|
|
700
700
|
}
|
|
701
701
|
const fn = this.fromDB
|
|
@@ -716,7 +716,7 @@ export class SqlRepository<T, ID, S> extends SqlSearchWriter<T, S> {
|
|
|
716
716
|
exist(id: ID, ctx?: Transaction): Promise<boolean> {
|
|
717
717
|
const field = this.primaryKeys[0].column ? this.primaryKeys[0].column : this.primaryKeys[0].name
|
|
718
718
|
const stmt = exist<ID>(id, this.table, this.primaryKeys, this.param, field)
|
|
719
|
-
if (!stmt) {
|
|
719
|
+
if (!stmt.query) {
|
|
720
720
|
throw new Error("cannot build query by id")
|
|
721
721
|
}
|
|
722
722
|
const db = ctx ? ctx : this.db
|
|
@@ -728,7 +728,7 @@ export class SqlRepository<T, ID, S> extends SqlSearchWriter<T, S> {
|
|
|
728
728
|
const db = ctx ? ctx : this.db
|
|
729
729
|
return db.exec(stmt.query, stmt.params)
|
|
730
730
|
} else {
|
|
731
|
-
|
|
731
|
+
throw new Error("cannot build delete query by id")
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
734
|
}
|
|
@@ -804,7 +804,7 @@ export class Query<T, ID, S> extends SearchBuilder<T, S> {
|
|
|
804
804
|
exist(id: ID, ctx?: any): Promise<boolean> {
|
|
805
805
|
const field = this.primaryKeys[0].column ? this.primaryKeys[0].column : this.primaryKeys[0].name
|
|
806
806
|
const stmt = exist<ID>(id, this.table, this.primaryKeys, this.param, field)
|
|
807
|
-
if (stmt.query) {
|
|
807
|
+
if (!stmt.query) {
|
|
808
808
|
throw new Error("cannot build query by id")
|
|
809
809
|
}
|
|
810
810
|
return this.query(stmt.query, stmt.params, undefined, undefined, ctx).then((res) => (!res || res.length === 0 ? false : true))
|