backend-plus 2.1.5 → 2.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.
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ForeignKey, FieldDefinition } from "backend-plus";
|
|
2
|
+
export type Key = string[];
|
|
3
|
+
export type Stores = {
|
|
4
|
+
[key: string]: IDBObjectStore;
|
|
5
|
+
};
|
|
6
|
+
export type StoreDefs = {
|
|
7
|
+
[key: string]: Key | string;
|
|
8
|
+
};
|
|
9
|
+
export type Record = {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
export interface TableDefinition {
|
|
13
|
+
name: string;
|
|
14
|
+
primaryKey: string[];
|
|
15
|
+
foreignKeys?: ForeignKey[];
|
|
16
|
+
softForeignKeys?: ForeignKey[];
|
|
17
|
+
fields: FieldDefinition[];
|
|
18
|
+
}
|
|
19
|
+
type RegisterResult = {
|
|
20
|
+
new?: true;
|
|
21
|
+
dataErased?: true;
|
|
22
|
+
changed: boolean;
|
|
23
|
+
};
|
|
24
|
+
type DetectFeatures = {
|
|
25
|
+
needToUnwrapArrayKeys: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare var detectedFeatures: DetectFeatures;
|
|
28
|
+
export declare class LocalDb {
|
|
29
|
+
name: string;
|
|
30
|
+
private wait4db;
|
|
31
|
+
private wait4detectedFeatures;
|
|
32
|
+
constructor(name: string);
|
|
33
|
+
static deleteDatabase(name: string): Promise<void>;
|
|
34
|
+
private IDBX;
|
|
35
|
+
registerStructure(tableDef: TableDefinition): Promise<RegisterResult>;
|
|
36
|
+
detectFeatures(store: IDBObjectStore): Promise<DetectFeatures>;
|
|
37
|
+
private registerStructureInside;
|
|
38
|
+
getStructure(tableName: string): Promise<TableDefinition>;
|
|
39
|
+
existsStructure(tableName: string): Promise<boolean>;
|
|
40
|
+
getOneIfExists<T>(tableName: string, key: Key): Promise<T | undefined>;
|
|
41
|
+
getOne<T>(tableName: string, key: Key): Promise<T>;
|
|
42
|
+
getChild<T>(tableName: string, parentKey: Key): Promise<T[]>;
|
|
43
|
+
getAll<T>(tableName: string): Promise<T[]>;
|
|
44
|
+
getAllStructures<T>(): Promise<T[]>;
|
|
45
|
+
isEmpty(tableName: string): Promise<boolean>;
|
|
46
|
+
private putOneAndGetIfNeeded;
|
|
47
|
+
putOne<T>(tableName: string, element: T): Promise<T>;
|
|
48
|
+
putMany<T>(tableName: string, elements: T[]): Promise<void>;
|
|
49
|
+
close(): Promise<void>;
|
|
50
|
+
clear(tableName: string): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
export declare class LocalDbTransaction {
|
|
53
|
+
localDbName: string;
|
|
54
|
+
private oneByOneChain;
|
|
55
|
+
constructor(localDbName: string);
|
|
56
|
+
inTransaction<T>(callback: (ldb: LocalDb) => Promise<T>): Promise<T>;
|
|
57
|
+
getBindedInTransaction<T>(): (callback: (ldb: LocalDb) => Promise<T>) => Promise<T>;
|
|
58
|
+
}
|
|
59
|
+
export {};
|