@naturalcycles/datastore-lib 3.37.0 → 3.38.0
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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CommonKeyValueDB, KeyValueDBTuple } from '@naturalcycles/db-lib';
|
|
2
|
+
import { StringMap } from '@naturalcycles/js-lib';
|
|
2
3
|
import { ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
3
4
|
import { DatastoreDB } from './datastore.db';
|
|
4
5
|
import { DatastoreDBCfg } from './datastore.model';
|
|
@@ -8,6 +9,10 @@ export declare class DatastoreKeyValueDB implements CommonKeyValueDB {
|
|
|
8
9
|
cfg: DatastoreKeyValueDBCfg;
|
|
9
10
|
constructor(cfg: DatastoreKeyValueDBCfg);
|
|
10
11
|
db: DatastoreDB;
|
|
12
|
+
support: {
|
|
13
|
+
increment: boolean;
|
|
14
|
+
count?: boolean;
|
|
15
|
+
};
|
|
11
16
|
ping(): Promise<void>;
|
|
12
17
|
createTable(): Promise<void>;
|
|
13
18
|
getByIds(table: string, ids: string[]): Promise<KeyValueDBTuple[]>;
|
|
@@ -18,4 +23,5 @@ export declare class DatastoreKeyValueDB implements CommonKeyValueDB {
|
|
|
18
23
|
streamEntries(table: string, limit?: number): ReadableTyped<KeyValueDBTuple>;
|
|
19
24
|
count(table: string): Promise<number>;
|
|
20
25
|
increment(_table: string, _id: string, _by?: number): Promise<number>;
|
|
26
|
+
incrementBatch(_table: string, _incrementMap: StringMap<number>): Promise<StringMap<number>>;
|
|
21
27
|
}
|
|
@@ -8,6 +8,10 @@ const excludeFromIndexes = ['v'];
|
|
|
8
8
|
class DatastoreKeyValueDB {
|
|
9
9
|
constructor(cfg) {
|
|
10
10
|
this.cfg = cfg;
|
|
11
|
+
this.support = {
|
|
12
|
+
...db_lib_1.commonKeyValueDBFullSupport,
|
|
13
|
+
increment: false,
|
|
14
|
+
};
|
|
11
15
|
this.db = new datastore_db_1.DatastoreDB(cfg);
|
|
12
16
|
}
|
|
13
17
|
async ping() {
|
|
@@ -56,5 +60,8 @@ class DatastoreKeyValueDB {
|
|
|
56
60
|
async increment(_table, _id, _by) {
|
|
57
61
|
throw new js_lib_1.AppError('DatastoreKeyValueDB.increment() is not implemented');
|
|
58
62
|
}
|
|
63
|
+
async incrementBatch(_table, _incrementMap) {
|
|
64
|
+
throw new js_lib_1.AppError('DatastoreKeyValueDB.incrementBatch() is not implemented');
|
|
65
|
+
}
|
|
59
66
|
}
|
|
60
67
|
exports.DatastoreKeyValueDB = DatastoreKeyValueDB;
|
package/package.json
CHANGED
package/src/datastore.db.ts
CHANGED
|
@@ -80,7 +80,8 @@ const methodMap: Record<CommonDBSaveMethod, string> = {
|
|
|
80
80
|
export class DatastoreDB extends BaseCommonDB implements CommonDB {
|
|
81
81
|
override support: CommonDBSupport = {
|
|
82
82
|
...commonDBFullSupport,
|
|
83
|
-
|
|
83
|
+
patchByQuery: false,
|
|
84
|
+
increment: false,
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
constructor(cfg: DatastoreDBCfg = {}) {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
CommonKeyValueDB,
|
|
3
|
+
commonKeyValueDBFullSupport,
|
|
4
|
+
DBQuery,
|
|
5
|
+
KeyValueDBTuple,
|
|
6
|
+
} from '@naturalcycles/db-lib'
|
|
7
|
+
import { AppError, StringMap } from '@naturalcycles/js-lib'
|
|
3
8
|
import { ReadableTyped } from '@naturalcycles/nodejs-lib'
|
|
4
9
|
import { DatastoreDB } from './datastore.db'
|
|
5
10
|
import { DatastoreDBCfg } from './datastore.model'
|
|
@@ -20,6 +25,11 @@ export class DatastoreKeyValueDB implements CommonKeyValueDB {
|
|
|
20
25
|
|
|
21
26
|
db: DatastoreDB
|
|
22
27
|
|
|
28
|
+
support = {
|
|
29
|
+
...commonKeyValueDBFullSupport,
|
|
30
|
+
increment: false,
|
|
31
|
+
}
|
|
32
|
+
|
|
23
33
|
async ping(): Promise<void> {
|
|
24
34
|
await this.db.ping()
|
|
25
35
|
}
|
|
@@ -88,4 +98,11 @@ export class DatastoreKeyValueDB implements CommonKeyValueDB {
|
|
|
88
98
|
async increment(_table: string, _id: string, _by?: number): Promise<number> {
|
|
89
99
|
throw new AppError('DatastoreKeyValueDB.increment() is not implemented')
|
|
90
100
|
}
|
|
101
|
+
|
|
102
|
+
async incrementBatch(
|
|
103
|
+
_table: string,
|
|
104
|
+
_incrementMap: StringMap<number>,
|
|
105
|
+
): Promise<StringMap<number>> {
|
|
106
|
+
throw new AppError('DatastoreKeyValueDB.incrementBatch() is not implemented')
|
|
107
|
+
}
|
|
91
108
|
}
|