@naturalcycles/datastore-lib 3.36.0 → 3.37.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.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export declare class DatastoreDBTransaction implements DBTransaction {
|
|
|
66
66
|
tx: Transaction;
|
|
67
67
|
constructor(db: DatastoreDB, tx: Transaction);
|
|
68
68
|
rollback(): Promise<void>;
|
|
69
|
-
getByIds<ROW extends ObjectWithId>(table: string, ids: string[], opt?: CommonDBOptions
|
|
70
|
-
saveBatch<ROW extends ObjectWithId>(table: string, rows: ROW[], opt?: CommonDBSaveOptions<ROW>
|
|
71
|
-
deleteByIds(table: string, ids: string[], opt?: CommonDBOptions
|
|
69
|
+
getByIds<ROW extends ObjectWithId>(table: string, ids: string[], opt?: CommonDBOptions): Promise<ROW[]>;
|
|
70
|
+
saveBatch<ROW extends ObjectWithId>(table: string, rows: ROW[], opt?: CommonDBSaveOptions<ROW>): Promise<void>;
|
|
71
|
+
deleteByIds(table: string, ids: string[], opt?: CommonDBOptions): Promise<number>;
|
|
72
72
|
}
|
|
@@ -17,4 +17,5 @@ export declare class DatastoreKeyValueDB implements CommonKeyValueDB {
|
|
|
17
17
|
streamValues(table: string, limit?: number): ReadableTyped<Buffer>;
|
|
18
18
|
streamEntries(table: string, limit?: number): ReadableTyped<KeyValueDBTuple>;
|
|
19
19
|
count(table: string): Promise<number>;
|
|
20
|
+
increment(_table: string, _id: string, _by?: number): Promise<number>;
|
|
20
21
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DatastoreKeyValueDB = void 0;
|
|
4
4
|
const db_lib_1 = require("@naturalcycles/db-lib");
|
|
5
|
+
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
6
|
const datastore_db_1 = require("./datastore.db");
|
|
6
7
|
const excludeFromIndexes = ['v'];
|
|
7
8
|
class DatastoreKeyValueDB {
|
|
@@ -52,5 +53,8 @@ class DatastoreKeyValueDB {
|
|
|
52
53
|
const q = db_lib_1.DBQuery.create(table);
|
|
53
54
|
return await this.db.runQueryCount(q);
|
|
54
55
|
}
|
|
56
|
+
async increment(_table, _id, _by) {
|
|
57
|
+
throw new js_lib_1.AppError('DatastoreKeyValueDB.increment() is not implemented');
|
|
58
|
+
}
|
|
55
59
|
}
|
|
56
60
|
exports.DatastoreKeyValueDB = DatastoreKeyValueDB;
|
package/package.json
CHANGED
package/src/datastore.db.ts
CHANGED
|
@@ -571,7 +571,7 @@ export class DatastoreDBTransaction implements DBTransaction {
|
|
|
571
571
|
async getByIds<ROW extends ObjectWithId>(
|
|
572
572
|
table: string,
|
|
573
573
|
ids: string[],
|
|
574
|
-
opt?: CommonDBOptions
|
|
574
|
+
opt?: CommonDBOptions,
|
|
575
575
|
): Promise<ROW[]> {
|
|
576
576
|
return await this.db.getByIds(table, ids, { ...opt, tx: this })
|
|
577
577
|
}
|
|
@@ -579,16 +579,12 @@ export class DatastoreDBTransaction implements DBTransaction {
|
|
|
579
579
|
async saveBatch<ROW extends ObjectWithId>(
|
|
580
580
|
table: string,
|
|
581
581
|
rows: ROW[],
|
|
582
|
-
opt?: CommonDBSaveOptions<ROW
|
|
582
|
+
opt?: CommonDBSaveOptions<ROW>,
|
|
583
583
|
): Promise<void> {
|
|
584
584
|
await this.db.saveBatch(table, rows, { ...opt, tx: this })
|
|
585
585
|
}
|
|
586
586
|
|
|
587
|
-
async deleteByIds(
|
|
588
|
-
table: string,
|
|
589
|
-
ids: string[],
|
|
590
|
-
opt?: CommonDBOptions | undefined,
|
|
591
|
-
): Promise<number> {
|
|
587
|
+
async deleteByIds(table: string, ids: string[], opt?: CommonDBOptions): Promise<number> {
|
|
592
588
|
return await this.db.deleteByIds(table, ids, { ...opt, tx: this })
|
|
593
589
|
}
|
|
594
590
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CommonKeyValueDB, DBQuery, KeyValueDBTuple } from '@naturalcycles/db-lib'
|
|
2
|
+
import { AppError } 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'
|
|
@@ -83,4 +84,8 @@ export class DatastoreKeyValueDB implements CommonKeyValueDB {
|
|
|
83
84
|
const q = DBQuery.create<KVObject>(table)
|
|
84
85
|
return await this.db.runQueryCount(q)
|
|
85
86
|
}
|
|
87
|
+
|
|
88
|
+
async increment(_table: string, _id: string, _by?: number): Promise<number> {
|
|
89
|
+
throw new AppError('DatastoreKeyValueDB.increment() is not implemented')
|
|
90
|
+
}
|
|
86
91
|
}
|