@naturalcycles/db-lib 10.58.0 → 10.59.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.
@@ -7,6 +7,7 @@ import type { FileDBPersistencePlugin } from './file.db.model.js';
7
7
  export declare class InMemoryPersistencePlugin implements FileDBPersistencePlugin {
8
8
  data: StringMap<StringMap<ObjectWithId>>;
9
9
  ping(): Promise<void>;
10
+ clear(): void;
10
11
  getTables(): Promise<string[]>;
11
12
  loadFile<ROW extends ObjectWithId>(table: string): Promise<ROW[]>;
12
13
  saveFiles(ops: DBSaveBatchOperation<any>[]): Promise<void>;
@@ -5,6 +5,9 @@ import { _by } from '@naturalcycles/js-lib/array/array.util.js';
5
5
  export class InMemoryPersistencePlugin {
6
6
  data = {};
7
7
  async ping() { }
8
+ clear() {
9
+ this.data = {};
10
+ }
8
11
  async getTables() {
9
12
  return Object.keys(this.data);
10
13
  }
@@ -42,6 +42,7 @@ export declare class InMemoryDB implements CommonDB {
42
42
  */
43
43
  getDataSnapshot(): StringMap<StringMap<ObjectWithId>>;
44
44
  ping(): Promise<void>;
45
+ clear(): void;
45
46
  /**
46
47
  * Resets InMemory DB data
47
48
  */
@@ -33,6 +33,9 @@ export class InMemoryDB {
33
33
  return _sortObjectDeep(this.data);
34
34
  }
35
35
  async ping() { }
36
+ clear() {
37
+ this.data = {};
38
+ }
36
39
  /**
37
40
  * Resets InMemory DB data
38
41
  */
@@ -13,6 +13,7 @@ export declare class InMemoryKeyValueDB implements CommonKeyValueDB {
13
13
  };
14
14
  data: StringMap<StringMap<any>>;
15
15
  ping(): Promise<void>;
16
+ clear(): void;
16
17
  createTable(_table: string, _opt?: CommonDBCreateOptions): Promise<void>;
17
18
  deleteByIds(table: string, ids: string[]): Promise<void>;
18
19
  getByIds(table: string, ids: string[]): Promise<KeyValueDBTuple[]>;
@@ -11,6 +11,9 @@ export class InMemoryKeyValueDB {
11
11
  // data[table][id] => any (can be Buffer, or number)
12
12
  data = {};
13
13
  async ping() { }
14
+ clear() {
15
+ this.data = {};
16
+ }
14
17
  async createTable(_table, _opt) { }
15
18
  async deleteByIds(table, ids) {
16
19
  this.data[table] ||= {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/db-lib",
3
3
  "type": "module",
4
- "version": "10.58.0",
4
+ "version": "10.59.0",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@naturalcycles/nodejs-lib": "^15"
@@ -11,6 +11,10 @@ export class InMemoryPersistencePlugin implements FileDBPersistencePlugin {
11
11
 
12
12
  async ping(): Promise<void> {}
13
13
 
14
+ clear(): void {
15
+ this.data = {}
16
+ }
17
+
14
18
  async getTables(): Promise<string[]> {
15
19
  return Object.keys(this.data)
16
20
  }
@@ -88,6 +88,10 @@ export class InMemoryDB implements CommonDB {
88
88
 
89
89
  async ping(): Promise<void> {}
90
90
 
91
+ clear(): void {
92
+ this.data = {}
93
+ }
94
+
91
95
  /**
92
96
  * Resets InMemory DB data
93
97
  */
@@ -18,6 +18,10 @@ export class InMemoryKeyValueDB implements CommonKeyValueDB {
18
18
 
19
19
  async ping(): Promise<void> {}
20
20
 
21
+ clear(): void {
22
+ this.data = {}
23
+ }
24
+
21
25
  async createTable(_table: string, _opt?: CommonDBCreateOptions): Promise<void> {}
22
26
 
23
27
  async deleteByIds(table: string, ids: string[]): Promise<void> {