@naturalcycles/datastore-lib 3.38.0 → 3.38.2
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/datastore.db.js
CHANGED
|
@@ -206,9 +206,7 @@ class DatastoreDB extends db_lib_1.BaseCommonDB {
|
|
|
206
206
|
*/
|
|
207
207
|
async deleteByIds(table, ids, opt = {}) {
|
|
208
208
|
const keys = ids.map(id => this.key(table, id));
|
|
209
|
-
await (0, js_lib_1.pMap)((0, js_lib_1._chunk)(keys, MAX_ITEMS),
|
|
210
|
-
// eslint-disable-next-line @typescript-eslint/return-await
|
|
211
|
-
async (batch) => await (opt.tx?.tx || this.ds()).delete(batch), {
|
|
209
|
+
await (0, js_lib_1.pMap)((0, js_lib_1._chunk)(keys, MAX_ITEMS), async (batch) => await (opt.tx?.tx || this.ds()).delete(batch), {
|
|
212
210
|
concurrency: DATASTORE_RECOMMENDED_CONCURRENCY,
|
|
213
211
|
});
|
|
214
212
|
return ids.length;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CommonKeyValueDB, KeyValueDBTuple } from '@naturalcycles/db-lib';
|
|
2
|
-
import {
|
|
2
|
+
import { IncrementTuple } from '@naturalcycles/db-lib/dist/kv/commonKeyValueDB';
|
|
3
3
|
import { ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
4
4
|
import { DatastoreDB } from './datastore.db';
|
|
5
5
|
import { DatastoreDBCfg } from './datastore.model';
|
|
@@ -22,6 +22,5 @@ export declare class DatastoreKeyValueDB implements CommonKeyValueDB {
|
|
|
22
22
|
streamValues(table: string, limit?: number): ReadableTyped<Buffer>;
|
|
23
23
|
streamEntries(table: string, limit?: number): ReadableTyped<KeyValueDBTuple>;
|
|
24
24
|
count(table: string): Promise<number>;
|
|
25
|
-
|
|
26
|
-
incrementBatch(_table: string, _incrementMap: StringMap<number>): Promise<StringMap<number>>;
|
|
25
|
+
incrementBatch(_table: string, _entries: IncrementTuple[]): Promise<IncrementTuple[]>;
|
|
27
26
|
}
|
|
@@ -57,10 +57,7 @@ class DatastoreKeyValueDB {
|
|
|
57
57
|
const q = db_lib_1.DBQuery.create(table);
|
|
58
58
|
return await this.db.runQueryCount(q);
|
|
59
59
|
}
|
|
60
|
-
async
|
|
61
|
-
throw new js_lib_1.AppError('DatastoreKeyValueDB.increment() is not implemented');
|
|
62
|
-
}
|
|
63
|
-
async incrementBatch(_table, _incrementMap) {
|
|
60
|
+
async incrementBatch(_table, _entries) {
|
|
64
61
|
throw new js_lib_1.AppError('DatastoreKeyValueDB.incrementBatch() is not implemented');
|
|
65
62
|
}
|
|
66
63
|
}
|
package/package.json
CHANGED
package/src/datastore.db.ts
CHANGED
|
@@ -350,7 +350,7 @@ export class DatastoreDB extends BaseCommonDB implements CommonDB {
|
|
|
350
350
|
|
|
351
351
|
await pMap(
|
|
352
352
|
_chunk(keys, MAX_ITEMS),
|
|
353
|
-
|
|
353
|
+
|
|
354
354
|
async batch => await ((opt.tx as DatastoreDBTransaction)?.tx || this.ds()).delete(batch),
|
|
355
355
|
{
|
|
356
356
|
concurrency: DATASTORE_RECOMMENDED_CONCURRENCY,
|
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
DBQuery,
|
|
5
5
|
KeyValueDBTuple,
|
|
6
6
|
} from '@naturalcycles/db-lib'
|
|
7
|
-
import {
|
|
7
|
+
import { IncrementTuple } from '@naturalcycles/db-lib/dist/kv/commonKeyValueDB'
|
|
8
|
+
import { AppError, ObjectWithId } from '@naturalcycles/js-lib'
|
|
8
9
|
import { ReadableTyped } from '@naturalcycles/nodejs-lib'
|
|
9
10
|
import { DatastoreDB } from './datastore.db'
|
|
10
11
|
import { DatastoreDBCfg } from './datastore.model'
|
|
@@ -55,7 +56,7 @@ export class DatastoreKeyValueDB implements CommonKeyValueDB {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
streamIds(table: string, limit?: number): ReadableTyped<string> {
|
|
58
|
-
const q = DBQuery.create<
|
|
59
|
+
const q = DBQuery.create<ObjectWithId>(table)
|
|
59
60
|
.select(['id'])
|
|
60
61
|
.limit(limit || 0)
|
|
61
62
|
|
|
@@ -86,23 +87,16 @@ export class DatastoreKeyValueDB implements CommonKeyValueDB {
|
|
|
86
87
|
this.db
|
|
87
88
|
.streamQuery(q)
|
|
88
89
|
// .on('error', err => stream.emit('error', err))
|
|
89
|
-
.map(r => [r.id, r.v]
|
|
90
|
+
.map(r => [r.id, r.v])
|
|
90
91
|
)
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
async count(table: string): Promise<number> {
|
|
94
|
-
const q = DBQuery.create<
|
|
95
|
+
const q = DBQuery.create<ObjectWithId>(table)
|
|
95
96
|
return await this.db.runQueryCount(q)
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
async
|
|
99
|
-
throw new AppError('DatastoreKeyValueDB.increment() is not implemented')
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async incrementBatch(
|
|
103
|
-
_table: string,
|
|
104
|
-
_incrementMap: StringMap<number>,
|
|
105
|
-
): Promise<StringMap<number>> {
|
|
99
|
+
async incrementBatch(_table: string, _entries: IncrementTuple[]): Promise<IncrementTuple[]> {
|
|
106
100
|
throw new AppError('DatastoreKeyValueDB.incrementBatch() is not implemented')
|
|
107
101
|
}
|
|
108
102
|
}
|