ueberdb2 4.1.4 → 4.1.6
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.
|
@@ -14,16 +14,39 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
17
40
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
41
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
42
|
};
|
|
20
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
44
|
exports.Database = void 0;
|
|
22
45
|
const AbstractDatabase_1 = __importDefault(require("../lib/AbstractDatabase"));
|
|
23
|
-
const assert_1 = require("assert");
|
|
46
|
+
const assert_1 = __importStar(require("assert"));
|
|
24
47
|
const buffer_1 = require("buffer");
|
|
25
48
|
const crypto_1 = require("crypto");
|
|
26
|
-
const
|
|
49
|
+
const elasticsearch8_1 = require("elasticsearch8");
|
|
27
50
|
const schema = '2';
|
|
28
51
|
const keyToId = (key) => {
|
|
29
52
|
const keyBuf = buffer_1.Buffer.from(key);
|
|
@@ -43,12 +66,12 @@ const migrateToSchema2 = async (client, v1BaseIndex, v2Index, logger) => {
|
|
|
43
66
|
const totals = new Map();
|
|
44
67
|
logger.info('Attempting elasticsearch record migration from schema v1 at base index ' +
|
|
45
68
|
`${v1BaseIndex} to schema v2 at index ${v2Index}...`);
|
|
46
|
-
const
|
|
69
|
+
const indices = await client.indices.get({ index: [v1BaseIndex, `${v1BaseIndex}-*-*`] });
|
|
47
70
|
const scrollIds = new Map();
|
|
48
71
|
const q = [];
|
|
49
72
|
try {
|
|
50
73
|
for (const index of Object.keys(indices)) {
|
|
51
|
-
const
|
|
74
|
+
const res = await client.search({ index, scroll: '10m' });
|
|
52
75
|
scrollIds.set(index, res._scroll_id);
|
|
53
76
|
q.push({ index, res });
|
|
54
77
|
}
|
|
@@ -72,18 +95,16 @@ const migrateToSchema2 = async (client, v1BaseIndex, v2Index, logger) => {
|
|
|
72
95
|
await client.bulk({ index: v2Index, body });
|
|
73
96
|
recordsMigrated += hits.length;
|
|
74
97
|
if (Math.floor(recordsMigrated / 100) > Math.floor(recordsMigratedLastLogged / 100)) {
|
|
75
|
-
// @ts-ignore
|
|
76
98
|
const total = [...totals.values()].reduce((a, b) => a + b, 0);
|
|
77
99
|
logger.info(`Migrated ${recordsMigrated} records out of ${total}`);
|
|
78
100
|
recordsMigratedLastLogged = recordsMigrated;
|
|
79
101
|
}
|
|
80
|
-
q.push({ index, res: (await client.scroll({ scroll: '5m',
|
|
102
|
+
q.push({ index, res: (await client.scroll({ scroll: '5m', scroll_id: scrollIds.get(index) })) });
|
|
81
103
|
}
|
|
82
104
|
logger.info(`Finished migrating ${recordsMigrated} records`);
|
|
83
105
|
}
|
|
84
106
|
finally {
|
|
85
|
-
|
|
86
|
-
await Promise.all([...scrollIds.values()].map((scrollId) => client.clearScroll({ scrollId })));
|
|
107
|
+
await Promise.all([...scrollIds.values()].map((scrollId) => client.clearScroll({ scroll_id: scrollId })));
|
|
87
108
|
}
|
|
88
109
|
};
|
|
89
110
|
const Database = class extends AbstractDatabase_1.default {
|
|
@@ -122,35 +143,33 @@ const Database = class extends AbstractDatabase_1.default {
|
|
|
122
143
|
*/
|
|
123
144
|
async init() {
|
|
124
145
|
// create elasticsearch client
|
|
125
|
-
const client = new
|
|
146
|
+
const client = new elasticsearch8_1.Client({
|
|
126
147
|
node: `http://${this.settings.host}:${this.settings.port}`,
|
|
127
148
|
});
|
|
128
149
|
await client.ping();
|
|
129
|
-
if (!(await client.indices.exists({ index: this._index }))
|
|
150
|
+
if (!(await client.indices.exists({ index: this._index }))) {
|
|
130
151
|
let tmpIndex;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (migrate && !this.settings.migrate_to_newer_schema) {
|
|
152
|
+
const exists = await client.indices.exists({ index: this.settings.base_index });
|
|
153
|
+
if (exists && !this.settings.migrate_to_newer_schema) {
|
|
134
154
|
throw new Error(`Data exists under the legacy index (schema) named ${this.settings.base_index}. ` +
|
|
135
155
|
'Set migrate_to_newer_schema to true to copy the existing data to a new index ' +
|
|
136
156
|
`named ${this._index}.`);
|
|
137
157
|
}
|
|
138
158
|
let attempt = 0;
|
|
139
159
|
while (true) {
|
|
140
|
-
tmpIndex = `${this._index}_${
|
|
141
|
-
if (!(await client.indices.exists({ index: tmpIndex }))
|
|
160
|
+
tmpIndex = `${this._index}_${exists ? 'migrate_attempt_' : 'i'}${attempt++}`;
|
|
161
|
+
if (!(await client.indices.exists({ index: tmpIndex })))
|
|
142
162
|
break;
|
|
143
163
|
}
|
|
144
|
-
await client.indices.create({ index: tmpIndex,
|
|
145
|
-
if (
|
|
164
|
+
await client.indices.create({ index: tmpIndex, mappings: mappings });
|
|
165
|
+
if (exists)
|
|
146
166
|
await migrateToSchema2(client, this.settings.base_index, tmpIndex, this.logger);
|
|
147
167
|
await client.indices.putAlias({ index: tmpIndex, name: this._index });
|
|
148
168
|
}
|
|
149
|
-
const indices = Object.values((await client.indices.get({ index: this._index }))
|
|
169
|
+
const indices = Object.values((await client.indices.get({ index: this._index })));
|
|
150
170
|
(0, assert_1.equal)(indices.length, 1);
|
|
151
171
|
try {
|
|
152
|
-
|
|
153
|
-
assert.deepEqual(indices[0].mappings, mappings);
|
|
172
|
+
assert_1.default.deepEqual(indices[0].mappings, mappings);
|
|
154
173
|
}
|
|
155
174
|
catch (err) {
|
|
156
175
|
this.logger.warn(`Index ${this._index} mappings does not match expected; ` +
|
|
@@ -164,10 +183,10 @@ const Database = class extends AbstractDatabase_1.default {
|
|
|
164
183
|
* @param {String} key Key
|
|
165
184
|
*/
|
|
166
185
|
async get(key) {
|
|
167
|
-
const
|
|
168
|
-
if (!
|
|
186
|
+
const res = await this._client.get({ ...this._q, id: keyToId(key) }, { ignore: [404] });
|
|
187
|
+
if (!res.found)
|
|
169
188
|
return null;
|
|
170
|
-
return
|
|
189
|
+
return res._source.value;
|
|
171
190
|
}
|
|
172
191
|
/**
|
|
173
192
|
* @param key Search key, which uses an asterisk (*) as the wild card.
|
|
@@ -188,8 +207,8 @@ const Database = class extends AbstractDatabase_1.default {
|
|
|
188
207
|
},
|
|
189
208
|
},
|
|
190
209
|
};
|
|
191
|
-
const {
|
|
192
|
-
return hits.map((h) => h._source.key);
|
|
210
|
+
const { hits: hits } = await this._client.search(q);
|
|
211
|
+
return hits.hits.map((h) => h._source.key);
|
|
193
212
|
}
|
|
194
213
|
/**
|
|
195
214
|
* This function provides write functionality to the database.
|
|
@@ -237,7 +256,6 @@ const Database = class extends AbstractDatabase_1.default {
|
|
|
237
256
|
operations.push({ delete: { _id: keyToId(key) } });
|
|
238
257
|
break;
|
|
239
258
|
default:
|
|
240
|
-
continue;
|
|
241
259
|
}
|
|
242
260
|
}
|
|
243
261
|
await this._client.bulk({ ...this._q, body: operations });
|
package/dist/test/test.js
CHANGED
|
@@ -32,14 +32,12 @@ const wtfnode_1 = __importDefault(require("wtfnode"));
|
|
|
32
32
|
const cli_table_1 = __importDefault(require("cli-table"));
|
|
33
33
|
// @ts-ignore
|
|
34
34
|
const randexp_1 = __importDefault(require("randexp"));
|
|
35
|
-
const assert_1 = __importDefault(require("assert"));
|
|
36
35
|
const databases_1 = require("./lib/databases");
|
|
37
36
|
const fs_1 = require("fs");
|
|
38
37
|
const logging_1 = __importDefault(require("../lib/logging"));
|
|
39
38
|
const ueberdb = __importStar(require("../index"));
|
|
40
39
|
'use strict';
|
|
41
|
-
const
|
|
42
|
-
const databases = { databases: databases_1.databases }.databases;
|
|
40
|
+
const assert_1 = require("assert");
|
|
43
41
|
const fs = { promises: fs_1.promises }.promises;
|
|
44
42
|
const maxKeyLength = 100;
|
|
45
43
|
const randomString = (length = maxKeyLength) => new randexp_1.default(new RegExp(`.{${length}}`)).gen();
|
|
@@ -77,10 +75,9 @@ describe(__filename, () => {
|
|
|
77
75
|
after(async () => {
|
|
78
76
|
console.log(speedTable.toString());
|
|
79
77
|
});
|
|
80
|
-
Object.keys(databases)
|
|
78
|
+
Object.keys(databases_1.databases)
|
|
81
79
|
.forEach((database) => {
|
|
82
|
-
|
|
83
|
-
const dbSettings = databases[database];
|
|
80
|
+
const dbSettings = databases_1.databases[database];
|
|
84
81
|
describe(database, () => {
|
|
85
82
|
for (const readCache of [false, true]) {
|
|
86
83
|
describe(`${readCache ? '' : 'no '}read cache`, () => {
|
|
@@ -115,19 +112,16 @@ describe(__filename, () => {
|
|
|
115
112
|
});
|
|
116
113
|
it('get(key) -> record', async () => {
|
|
117
114
|
const output = await db.get(key);
|
|
118
|
-
|
|
119
|
-
assert.equal(JSON.stringify(output), JSON.stringify(input));
|
|
115
|
+
(0, assert_1.equal)(JSON.stringify(output), JSON.stringify(input));
|
|
120
116
|
});
|
|
121
117
|
it('get(`${key} `) -> nullish', async () => {
|
|
122
118
|
const output = await db.get(`${key} `);
|
|
123
|
-
|
|
124
|
-
assert(output == null);
|
|
119
|
+
(0, assert_1.equal)(output == null, true);
|
|
125
120
|
});
|
|
126
121
|
if (space) {
|
|
127
122
|
it('get(key.slice(0, -1)) -> nullish', async () => {
|
|
128
123
|
const output = await db.get(key.slice(0, -1));
|
|
129
|
-
|
|
130
|
-
assert(output == null);
|
|
124
|
+
(0, assert_1.equal)(output == null, true);
|
|
131
125
|
});
|
|
132
126
|
}
|
|
133
127
|
});
|
|
@@ -135,24 +129,21 @@ describe(__filename, () => {
|
|
|
135
129
|
});
|
|
136
130
|
it('get of unknown key -> nullish', async () => {
|
|
137
131
|
const key = randomString();
|
|
138
|
-
|
|
139
|
-
assert((await db.get(key)) == null);
|
|
132
|
+
(0, assert_1.equal)((await db.get(key)) == null, true);
|
|
140
133
|
});
|
|
141
134
|
it('set+get works', async () => {
|
|
142
135
|
const input = { a: 1, b: new randexp_1.default(/.+/).gen() };
|
|
143
136
|
const key = randomString();
|
|
144
137
|
await db.set(key, input);
|
|
145
138
|
const output = await db.get(key);
|
|
146
|
-
|
|
147
|
-
assert.equal(JSON.stringify(output), JSON.stringify(input));
|
|
139
|
+
(0, assert_1.equal)(JSON.stringify(output), JSON.stringify(input));
|
|
148
140
|
});
|
|
149
141
|
it('set+get with random key/value works', async () => {
|
|
150
142
|
const input = { testLongString: new randexp_1.default(/[a-f0-9]{50000}/).gen() };
|
|
151
143
|
const key = randomString();
|
|
152
144
|
await db.set(key, input);
|
|
153
145
|
const output = await db.get(key);
|
|
154
|
-
|
|
155
|
-
assert.equal(JSON.stringify(output), JSON.stringify(input));
|
|
146
|
+
(0, assert_1.equal)(JSON.stringify(output), JSON.stringify(input));
|
|
156
147
|
});
|
|
157
148
|
it('findKeys works', async function () {
|
|
158
149
|
if (database === 'mongodb') {
|
|
@@ -166,8 +157,7 @@ describe(__filename, () => {
|
|
|
166
157
|
db.set(`nonmatching_${key}`, false),
|
|
167
158
|
]);
|
|
168
159
|
const keys = await db.findKeys(`${key}*`, null);
|
|
169
|
-
|
|
170
|
-
assert.deepEqual(keys.sort(), [key, `${key}a`]);
|
|
160
|
+
(0, assert_1.deepEqual)(keys.sort(), [key, `${key}a`]);
|
|
171
161
|
});
|
|
172
162
|
it('findKeys with exclusion works', async function () {
|
|
173
163
|
if (database === 'mongodb') {
|
|
@@ -182,96 +172,74 @@ describe(__filename, () => {
|
|
|
182
172
|
db.set(`nonmatching_${key}`, false),
|
|
183
173
|
]);
|
|
184
174
|
const keys = await db.findKeys(`${key}*`, `${key}b*`);
|
|
185
|
-
|
|
186
|
-
assert.deepEqual(keys.sort(), [key, `${key}a`].sort());
|
|
175
|
+
(0, assert_1.deepEqual)(keys.sort(), [key, `${key}a`].sort());
|
|
187
176
|
});
|
|
188
177
|
it('findKeys with no matches works', async () => {
|
|
189
178
|
const key = new randexp_1.default(/([a-z]\w{0,20})foo\1/).gen();
|
|
190
179
|
await db.set(key, true);
|
|
191
180
|
const keys = await db.findKeys(`${key}_nomatch_*`, null);
|
|
192
|
-
|
|
193
|
-
assert.deepEqual(keys, []);
|
|
181
|
+
(0, assert_1.deepEqual)(keys, []);
|
|
194
182
|
});
|
|
195
183
|
it('findKeys with no wildcard works', async () => {
|
|
196
184
|
const key = new randexp_1.default(/([a-z]\w{0,20})foo\1/).gen();
|
|
197
185
|
await db.set(key, true);
|
|
198
186
|
const keys = await db.findKeys(key, null);
|
|
199
|
-
|
|
200
|
-
assert.deepEqual(keys, [key]);
|
|
187
|
+
(0, assert_1.deepEqual)(keys, [key]);
|
|
201
188
|
});
|
|
202
189
|
it('remove works', async () => {
|
|
203
190
|
const input = { a: 1, b: new randexp_1.default(/.+/).gen() };
|
|
204
191
|
const key = randomString();
|
|
205
192
|
await db.set(key, input);
|
|
206
|
-
|
|
207
|
-
assert.equal(JSON.stringify(await db.get(key)), JSON.stringify(input));
|
|
193
|
+
(0, assert_1.equal)(JSON.stringify(await db.get(key)), JSON.stringify(input));
|
|
208
194
|
await db.remove(key);
|
|
209
|
-
|
|
210
|
-
assert((await db.get(key)) == null);
|
|
195
|
+
(0, assert_1.equal)((await db.get(key)) == null, true);
|
|
211
196
|
});
|
|
212
197
|
it('getSub of existing property works', async () => {
|
|
213
198
|
await db.set('k', { sub1: { sub2: 'v' } });
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
assert.deepEqual(await db.getSub('k', ['sub1']), { sub2: 'v' });
|
|
218
|
-
// @ts-expect-error TS(2775): Assertions require every name in the call target t... Remove this comment to see the full error message
|
|
219
|
-
assert.deepEqual(await db.getSub('k', []), { sub1: { sub2: 'v' } });
|
|
199
|
+
(0, assert_1.equal)(await db.getSub('k', ['sub1', 'sub2']), 'v');
|
|
200
|
+
(0, assert_1.deepEqual)(await db.getSub('k', ['sub1']), { sub2: 'v' });
|
|
201
|
+
(0, assert_1.deepEqual)(await db.getSub('k', []), { sub1: { sub2: 'v' } });
|
|
220
202
|
});
|
|
221
203
|
it('getSub of missing property returns nullish', async () => {
|
|
222
204
|
await db.set('k', { sub1: {} });
|
|
223
|
-
|
|
224
|
-
assert((await db.getSub('k', ['sub1', 'sub2'])) == null);
|
|
205
|
+
(0, assert_1.equal)((await db.getSub('k', ['sub1', 'sub2'])) == null, true);
|
|
225
206
|
await db.set('k', {});
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
// @ts-expect-error TS(2775): Assertions require every name in the call target t... Remove this comment to see the full error message
|
|
229
|
-
assert((await db.getSub('k', ['sub1'])) == null);
|
|
207
|
+
(0, assert_1.equal)((await db.getSub('k', ['sub1', 'sub2'])) == null, true);
|
|
208
|
+
(0, assert_1.equal)((await db.getSub('k', ['sub1'])) == null, true);
|
|
230
209
|
await db.remove('k');
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
assert((await db.getSub('k', ['sub1'])) == null);
|
|
235
|
-
// @ts-expect-error TS(2775): Assertions require every name in the call target t... Remove this comment to see the full error message
|
|
236
|
-
assert((await db.getSub('k', [])) == null);
|
|
210
|
+
(0, assert_1.equal)((await db.getSub('k', ['sub1', 'sub2'])) == null, true);
|
|
211
|
+
(0, assert_1.equal)((await db.getSub('k', ['sub1'])) == null, true);
|
|
212
|
+
(0, assert_1.equal)((await db.getSub('k', [])) == null, true);
|
|
237
213
|
});
|
|
238
214
|
it('setSub can modify an existing property', async () => {
|
|
239
215
|
await db.set('k', { sub1: { sub2: 'v' } });
|
|
240
216
|
await db.setSub('k', ['sub1', 'sub2'], 'v2');
|
|
241
|
-
|
|
242
|
-
assert.deepEqual(await db.get('k'), { sub1: { sub2: 'v2' } });
|
|
217
|
+
(0, assert_1.deepEqual)(await db.get('k'), { sub1: { sub2: 'v2' } });
|
|
243
218
|
await db.setSub('k', ['sub1'], 'v2');
|
|
244
|
-
|
|
245
|
-
assert.deepEqual(await db.get('k'), { sub1: 'v2' });
|
|
219
|
+
(0, assert_1.deepEqual)(await db.get('k'), { sub1: 'v2' });
|
|
246
220
|
await db.setSub('k', [], 'v3');
|
|
247
|
-
|
|
248
|
-
assert.equal(await db.get('k'), 'v3');
|
|
221
|
+
(0, assert_1.equal)(await db.get('k'), 'v3');
|
|
249
222
|
});
|
|
250
223
|
it('setSub can add a new property', async () => {
|
|
251
224
|
await db.remove('k');
|
|
252
225
|
await db.setSub('k', [], {});
|
|
253
|
-
|
|
254
|
-
assert.deepEqual(await db.get('k'), {});
|
|
226
|
+
(0, assert_1.deepEqual)(await db.get('k'), {});
|
|
255
227
|
await db.setSub('k', ['sub1'], {});
|
|
256
|
-
|
|
257
|
-
assert.deepEqual(await db.get('k'), { sub1: {} });
|
|
228
|
+
(0, assert_1.deepEqual)(await db.get('k'), { sub1: {} });
|
|
258
229
|
await db.setSub('k', ['sub1', 'sub2'], 'v');
|
|
259
|
-
|
|
260
|
-
assert.deepEqual(await db.get('k'), { sub1: { sub2: 'v' } });
|
|
230
|
+
(0, assert_1.deepEqual)(await db.get('k'), { sub1: { sub2: 'v' } });
|
|
261
231
|
await db.remove('k');
|
|
262
232
|
await db.setSub('k', ['sub1', 'sub2'], 'v');
|
|
263
|
-
|
|
264
|
-
assert.deepEqual(await db.get('k'), { sub1: { sub2: 'v' } });
|
|
233
|
+
(0, assert_1.deepEqual)(await db.get('k'), { sub1: { sub2: 'v' } });
|
|
265
234
|
});
|
|
266
235
|
it('setSub rejects attempts to set properties on primitives', async () => {
|
|
267
236
|
for (const v of ['hello world', 42, true]) {
|
|
268
237
|
await db.set('k', v);
|
|
269
|
-
|
|
238
|
+
await (0, assert_1.rejects)(db.setSub('k', ['sub'], 'x'), {
|
|
270
239
|
name: 'TypeError',
|
|
271
240
|
message: /property "sub" on non-object/,
|
|
272
241
|
});
|
|
273
|
-
|
|
274
|
-
assert.deepEqual(await db.get('k'), v);
|
|
242
|
+
(0, assert_1.deepEqual)(await db.get('k'), v);
|
|
275
243
|
}
|
|
276
244
|
});
|
|
277
245
|
it('speed is acceptable', async function () {
|
|
@@ -289,35 +257,27 @@ describe(__filename, () => {
|
|
|
289
257
|
}
|
|
290
258
|
promises[count] = db.flush();
|
|
291
259
|
await Promise.all(promises);
|
|
292
|
-
// @ts-expect-error TS(2339): Property 'set' does not exist on type '{ start: nu... Remove this comment to see the full error message
|
|
293
260
|
timers.set = Date.now();
|
|
294
261
|
for (let i = 0; i < count; ++i) {
|
|
295
262
|
promises[i] = db.get(key + i);
|
|
296
263
|
}
|
|
297
264
|
await Promise.all(promises);
|
|
298
|
-
// @ts-expect-error TS(2339): Property 'get' does not exist on type '{ start: nu... Remove this comment to see the full error message
|
|
299
265
|
timers.get = Date.now();
|
|
300
266
|
for (let i = 0; i < count; ++i) {
|
|
301
267
|
promises[i] = db.findKeys(key + i, null);
|
|
302
268
|
}
|
|
303
269
|
await Promise.all(promises);
|
|
304
|
-
// @ts-expect-error TS(2339): Property 'findKeys' does not exist on type '{ star... Remove this comment to see the full error message
|
|
305
270
|
timers.findKeys = Date.now();
|
|
306
271
|
for (let i = 0; i < count; ++i) {
|
|
307
272
|
promises[i] = db.remove(key + i);
|
|
308
273
|
}
|
|
309
274
|
promises[count] = db.flush();
|
|
310
275
|
await Promise.all(promises);
|
|
311
|
-
// @ts-expect-error TS(2339): Property 'remove' does not exist on type '{ start:... Remove this comment to see the full error message
|
|
312
276
|
timers.remove = Date.now();
|
|
313
277
|
const timePerOp = {
|
|
314
|
-
// @ts-expect-error TS(2339): Property 'set' does not exist on type '{ start: nu... Remove this comment to see the full error message
|
|
315
278
|
set: (timers.set - timers.start) / count,
|
|
316
|
-
// @ts-expect-error TS(2339): Property 'get' does not exist on type '{ start: nu... Remove this comment to see the full error message
|
|
317
279
|
get: (timers.get - timers.set) / count,
|
|
318
|
-
// @ts-expect-error TS(2339): Property 'findKeys' does not exist on type '{ star... Remove this comment to see the full error message
|
|
319
280
|
findKeys: (timers.findKeys - timers.get) / count,
|
|
320
|
-
// @ts-expect-error TS(2339): Property 'remove' does not exist on type '{ start:... Remove this comment to see the full error message
|
|
321
281
|
remove: (timers.remove - timers.findKeys) / count,
|
|
322
282
|
};
|
|
323
283
|
speedTable.push([
|
|
@@ -329,9 +289,7 @@ describe(__filename, () => {
|
|
|
329
289
|
timePerOp.get,
|
|
330
290
|
timePerOp.findKeys,
|
|
331
291
|
timePerOp.remove,
|
|
332
|
-
// @ts-expect-error TS(2339): Property 'remove' does not exist on type '{ start:... Remove this comment to see the full error message
|
|
333
292
|
timers.remove - timers.start,
|
|
334
|
-
// @ts-expect-error TS(2339): Property 'remove' does not exist on type '{ start:... Remove this comment to see the full error message
|
|
335
293
|
(timers.remove - timers.start) / count,
|
|
336
294
|
]);
|
|
337
295
|
// Removes the "Acceptable ms/op" column if there is no enforced limit.
|
|
@@ -354,14 +312,10 @@ describe(__filename, () => {
|
|
|
354
312
|
].map(filterColumn));
|
|
355
313
|
console.log(acceptableTable.toString());
|
|
356
314
|
if (readCache && writeBuffer) {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
// @ts-expect-error TS(2775): Assertions require every name in the call target t... Remove this comment to see the full error message
|
|
362
|
-
assert(findKeysMax >= timePerOp.findKeys);
|
|
363
|
-
// @ts-expect-error TS(2775): Assertions require every name in the call target t... Remove this comment to see the full error message
|
|
364
|
-
assert(removeMax >= timePerOp.remove);
|
|
315
|
+
(0, assert_1.equal)(setMax >= timePerOp.set, true);
|
|
316
|
+
(0, assert_1.equal)(getMax >= timePerOp.get, true);
|
|
317
|
+
(0, assert_1.equal)(findKeysMax >= timePerOp.findKeys, true);
|
|
318
|
+
(0, assert_1.equal)(removeMax >= timePerOp.remove, true);
|
|
365
319
|
}
|
|
366
320
|
});
|
|
367
321
|
});
|
|
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const assert_1 = require("assert");
|
|
30
|
-
const
|
|
30
|
+
const elasticsearch8_1 = __importDefault(require("elasticsearch8"));
|
|
31
31
|
const databases_1 = require("./lib/databases");
|
|
32
32
|
const logging_1 = __importDefault(require("../lib/logging"));
|
|
33
33
|
const ueberdb = __importStar(require("../index"));
|
|
@@ -43,7 +43,7 @@ describe(__filename, function () {
|
|
|
43
43
|
let client;
|
|
44
44
|
let db;
|
|
45
45
|
beforeEach(async () => {
|
|
46
|
-
client = new
|
|
46
|
+
client = new elasticsearch8_1.default.Client({
|
|
47
47
|
node: `http://${cfg.host || '127.0.0.1'}:${cfg.port || '9200'}`,
|
|
48
48
|
});
|
|
49
49
|
await client.indices.delete({ index: `${base_index}*` }, { ignore: [404] });
|
|
@@ -68,7 +68,7 @@ describe(__filename, function () {
|
|
|
68
68
|
db = new ueberdb.Database('elasticsearch', settings, {}, logger);
|
|
69
69
|
await db.init();
|
|
70
70
|
const indices = [];
|
|
71
|
-
const
|
|
71
|
+
const res = await client.indices.get({ index: `${base_index}*` });
|
|
72
72
|
for (const [k, v] of Object.entries(res)) {
|
|
73
73
|
indices.push(k);
|
|
74
74
|
// @ts-expect-error TS(2571): Object is of type 'unknown'.
|
|
@@ -129,7 +129,7 @@ describe(__filename, function () {
|
|
|
129
129
|
cfg.base_index = base_index;
|
|
130
130
|
const settings = { ...cfg, migrate_to_newer_schema: true };
|
|
131
131
|
db = new ueberdb.Database('elasticsearch', settings, {}, logger);
|
|
132
|
-
const getIndices = async () => Object.keys((await client.indices.get({ index: `${base_index}_s2*` }))
|
|
132
|
+
const getIndices = async () => Object.keys((await client.indices.get({ index: `${base_index}_s2*` })));
|
|
133
133
|
(0, assert_1.deepEqual)(await getIndices(), []);
|
|
134
134
|
await (0, assert_1.rejects)(db.init(), /ambig/);
|
|
135
135
|
(0, assert_1.deepEqual)(await getIndices(), [`${base_index}_s2_migrate_attempt_0`]);
|
package/dist/test/test_mysql.js
CHANGED
|
@@ -65,7 +65,6 @@ describe(__filename, () => {
|
|
|
65
65
|
});
|
|
66
66
|
it('queries run concurrently and are queued when pool is busy', async () => {
|
|
67
67
|
const connectionLimit = 10;
|
|
68
|
-
// @ts-expect-error TS(2339): Property 'Database' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
69
68
|
const db = new mysql.Database({ ...databases_1.databases.mysql, connectionLimit });
|
|
70
69
|
await db.init();
|
|
71
70
|
// Set the query duration high enough to avoid flakiness on slow machines but low enough to keep
|
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"async": "^3.2.4",
|
|
25
25
|
"cassandra-driver": "^4.6.4",
|
|
26
26
|
"dirty": "^1.1.3",
|
|
27
|
-
"
|
|
27
|
+
"elasticsearch8": "npm:@elastic/elasticsearch@^8.8.1",
|
|
28
28
|
"eslint-plugin-import": "^2.26.0",
|
|
29
29
|
"mongodb": "^3.7.3",
|
|
30
30
|
"mssql": "^9.1.1",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"@types/mongodb": "^4.0.7",
|
|
46
46
|
"@types/mssql": "^8.1.2",
|
|
47
47
|
"@types/mysql": "^2.15.21",
|
|
48
|
-
"@types/node": "^20.3.
|
|
48
|
+
"@types/node": "^20.3.3",
|
|
49
49
|
"@types/pg": "^8.10.2",
|
|
50
50
|
"@types/rethinkdb": "^2.3.17",
|
|
51
51
|
"cli-table": "^0.3.11",
|
|
52
|
-
"eslint": "^8.
|
|
52
|
+
"eslint": "^8.44.0",
|
|
53
53
|
"eslint-config-etherpad": "^3.0.13",
|
|
54
54
|
"mocha": "^10.2.0",
|
|
55
55
|
"randexp": "^0.5.3",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"url": "https://github.com/ether/ueberDB.git"
|
|
64
64
|
},
|
|
65
65
|
"main": "./dist/index",
|
|
66
|
-
"version": "4.1.
|
|
66
|
+
"version": "4.1.6",
|
|
67
67
|
"bugs": {
|
|
68
68
|
"url": "https://github.com/ether/ueberDB/issues"
|
|
69
69
|
},
|