@sprucelabs/postgres-data-store 2.0.6 → 2.0.8
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.
|
@@ -84,23 +84,21 @@ class PostgresDatabase {
|
|
|
84
84
|
return results.rowCount;
|
|
85
85
|
}
|
|
86
86
|
async dropDatabase() {
|
|
87
|
-
var _a;
|
|
88
87
|
await this.truncateTables();
|
|
89
88
|
const names = await this.getTables();
|
|
90
89
|
for (const name of names) {
|
|
91
|
-
|
|
92
|
-
await this.dropAllNonPrimaryKeyIndexes(name);
|
|
93
|
-
}
|
|
94
|
-
catch (err) {
|
|
95
|
-
console.error('Failed to drop indexe1');
|
|
96
|
-
console.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
|
|
97
|
-
}
|
|
90
|
+
await this.dropAllNonPrimaryKeyIndexes(name);
|
|
98
91
|
}
|
|
99
92
|
}
|
|
100
93
|
async dropAllNonPrimaryKeyIndexes(name) {
|
|
101
94
|
const indexNames = await this.getIndexNames(name);
|
|
102
95
|
for (const indexName of indexNames) {
|
|
103
|
-
|
|
96
|
+
try {
|
|
97
|
+
await this.client.query(`DROP INDEX ${indexName}`);
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
console.info('Failed to drop index', indexName, err.stack);
|
|
101
|
+
}
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
104
|
async getIndexNames(name) {
|
package/build/QueryBuilder.js
CHANGED
|
@@ -65,9 +65,10 @@ class QueryBuilder {
|
|
|
65
65
|
values.push(this.normalizeValue(value.$gt));
|
|
66
66
|
set.push(`${k} > $${++placeholderCount}`);
|
|
67
67
|
}
|
|
68
|
-
else if (value === null || value === void 0 ? void 0 : value.$ne) {
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
else if (typeof (value === null || value === void 0 ? void 0 : value.$ne) !== 'undefined') {
|
|
69
|
+
const v = value.$ne;
|
|
70
|
+
v !== null && values.push(this.normalizeValue(v));
|
|
71
|
+
set.push(`${k} ${v === null ? 'IS NOT NULL' : `!= $${++placeholderCount}`}`);
|
|
71
72
|
}
|
|
72
73
|
else if (k === '$or') {
|
|
73
74
|
const { set: orWheres, values: orValues } = this.buildSetClausFor$Or(value, placeholderCount);
|
|
@@ -106,18 +106,11 @@ export default class PostgresDatabase {
|
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
dropDatabase() {
|
|
109
|
-
var _a;
|
|
110
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
110
|
yield this.truncateTables();
|
|
112
111
|
const names = yield this.getTables();
|
|
113
112
|
for (const name of names) {
|
|
114
|
-
|
|
115
|
-
yield this.dropAllNonPrimaryKeyIndexes(name);
|
|
116
|
-
}
|
|
117
|
-
catch (err) {
|
|
118
|
-
console.error('Failed to drop indexe1');
|
|
119
|
-
console.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
|
|
120
|
-
}
|
|
113
|
+
yield this.dropAllNonPrimaryKeyIndexes(name);
|
|
121
114
|
}
|
|
122
115
|
});
|
|
123
116
|
}
|
|
@@ -125,7 +118,12 @@ export default class PostgresDatabase {
|
|
|
125
118
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
119
|
const indexNames = yield this.getIndexNames(name);
|
|
127
120
|
for (const indexName of indexNames) {
|
|
128
|
-
|
|
121
|
+
try {
|
|
122
|
+
yield this.client.query(`DROP INDEX ${indexName}`);
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
console.info('Failed to drop index', indexName, err.stack);
|
|
126
|
+
}
|
|
129
127
|
}
|
|
130
128
|
});
|
|
131
129
|
}
|
|
@@ -63,9 +63,10 @@ export default class QueryBuilder {
|
|
|
63
63
|
values.push(this.normalizeValue(value.$gt));
|
|
64
64
|
set.push(`${k} > $${++placeholderCount}`);
|
|
65
65
|
}
|
|
66
|
-
else if (value === null || value === void 0 ? void 0 : value.$ne) {
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
else if (typeof (value === null || value === void 0 ? void 0 : value.$ne) !== 'undefined') {
|
|
67
|
+
const v = value.$ne;
|
|
68
|
+
v !== null && values.push(this.normalizeValue(v));
|
|
69
|
+
set.push(`${k} ${v === null ? 'IS NOT NULL' : `!= $${++placeholderCount}`}`);
|
|
69
70
|
}
|
|
70
71
|
else if (k === '$or') {
|
|
71
72
|
const { set: orWheres, values: orValues } = this.buildSetClausFor$Or(value, placeholderCount);
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"sprucebot",
|
|
24
24
|
"sprucelabs"
|
|
25
25
|
],
|
|
26
|
-
"version": "2.0.
|
|
26
|
+
"version": "2.0.8",
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build.ci": "yarn build.tsc && yarn build.resolve-paths && yarn lint",
|
|
29
29
|
"build.dev": "yarn build.tsc --sourceMap ; yarn resolve-paths.lint",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"watch.tsc": "tsc -w"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@sprucelabs/data-stores": "^22.0
|
|
55
|
+
"@sprucelabs/data-stores": "^22.2.0",
|
|
56
56
|
"@sprucelabs/schema": "^28.5.141",
|
|
57
57
|
"pg": "^8.10.0"
|
|
58
58
|
},
|