@tblabs/storage 1.1.0 → 1.2.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/OnlineRepo.js +2 -2
- package/RefConverter.d.ts +11 -0
- package/RefConverter.js +36 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/tblabs-storage-1.2.0.tgz +0 -0
- package/tblabs-storage-1.1.0.tgz +0 -0
package/OnlineRepo.js
CHANGED
|
@@ -40,7 +40,7 @@ export class OnlineRepo {
|
|
|
40
40
|
return null;
|
|
41
41
|
}
|
|
42
42
|
async FindOne(id) {
|
|
43
|
-
this.Log(`
|
|
43
|
+
this.Log(`Searching for "${id}"...`);
|
|
44
44
|
const queryResult = await this._bus.SendMessage(new FindQuery(id, this.databaseFolder));
|
|
45
45
|
if (queryResult.IsSuccess) {
|
|
46
46
|
const item = queryResult.Result;
|
|
@@ -63,7 +63,7 @@ export class OnlineRepo {
|
|
|
63
63
|
throw new Error(`Could not fetch all from "${folder}": ${queryResult.ErrorMessage}`);
|
|
64
64
|
}
|
|
65
65
|
async GetAllIds(folder) {
|
|
66
|
-
this.Log(`Fetching all from "${this.databaseFolder}"...`);
|
|
66
|
+
this.Log(`Fetching all ids from "${this.databaseFolder}"...`);
|
|
67
67
|
const folderPath = this.databaseFolder + "/" + folder;
|
|
68
68
|
const queryResult = await this._bus.SendMessage(new ListQuery(folderPath, false));
|
|
69
69
|
if (queryResult.IsSuccess) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare abstract class RefConverter<R, T> {
|
|
2
|
+
protected abstract ConvertToRaw(obj: T): R | null;
|
|
3
|
+
protected abstract ConvertFromRaw(raw: R): T | null;
|
|
4
|
+
ToRaw(target: T): R | null;
|
|
5
|
+
FromRaw(raw: R): T | null;
|
|
6
|
+
protected GetArray<R, T>(value: R[], creator: (raw: R) => T): Array<T>;
|
|
7
|
+
protected GetString(value: any): string;
|
|
8
|
+
protected GetNumber(value: any): number;
|
|
9
|
+
protected GetBool(value: any): boolean;
|
|
10
|
+
protected GetDate(date: any): Date;
|
|
11
|
+
}
|
package/RefConverter.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export class RefConverter {
|
|
2
|
+
ToRaw(target) {
|
|
3
|
+
try {
|
|
4
|
+
return this.ConvertToRaw(target);
|
|
5
|
+
}
|
|
6
|
+
catch (ex) {
|
|
7
|
+
console.error(`Conversion from object to raw problem: ${ex.message}\n\nStack trace: ${ex.stack}\n\nObject:`, target);
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
FromRaw(raw) {
|
|
12
|
+
try {
|
|
13
|
+
return this.ConvertFromRaw(raw);
|
|
14
|
+
}
|
|
15
|
+
catch (ex) {
|
|
16
|
+
console.error(`Conversion from raw to object problem: ${ex.message}\n\nStack trace: ${ex.stack}\n\nRaw:`, raw);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
GetArray(value, creator) {
|
|
21
|
+
const items = value?.map(x => creator(x));
|
|
22
|
+
return items || [];
|
|
23
|
+
}
|
|
24
|
+
GetString(value) {
|
|
25
|
+
return value || "";
|
|
26
|
+
}
|
|
27
|
+
GetNumber(value) {
|
|
28
|
+
return +value || 0;
|
|
29
|
+
}
|
|
30
|
+
GetBool(value) {
|
|
31
|
+
return !!value || false;
|
|
32
|
+
}
|
|
33
|
+
GetDate(date) {
|
|
34
|
+
return date ? new Date(date) : new Date(0);
|
|
35
|
+
}
|
|
36
|
+
}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
Binary file
|
package/tblabs-storage-1.1.0.tgz
DELETED
|
Binary file
|