@tblabs/storage 5.0.0 → 5.0.1

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/Dataset.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare class Dataset<T extends object> implements IRepo<T> {
9
9
  get Name(): string;
10
10
  constructor(_db: OnlineStorage, _converter: IConverter<any, T>, dataset: dir);
11
11
  private get DatasetPath();
12
- GetOne(id: string): Promise<T | null>;
12
+ GetOne(id: string): Promise<T>;
13
13
  FindOne(id: string): Promise<T | null>;
14
14
  GetAll(): Promise<T[]>;
15
15
  Add(id: string, item: T): Promise<void>;
package/Dataset.js CHANGED
@@ -24,32 +24,29 @@ export class Dataset {
24
24
  this._db.Log(`Fetching "${id}"...`);
25
25
  const queryResult = await this._db.Send(new GetQuery(this._db.DatabaseDir, this.dataset, id));
26
26
  if (!queryResult.IsSuccess) {
27
- this._db.Log(`"${this.DatasetPath}/${id}" not found.`);
28
- return null;
27
+ throw new Error(`Could not fetch "${id}" from "${this.DatasetPath}": ${queryResult.ErrorMessage}`);
29
28
  }
30
- this._db.Log(`Found "${id}" in "${this.DatasetPath}".`);
31
29
  const rawItem = queryResult.Result;
32
30
  const item = this._converter.FromRaw(rawItem);
31
+ this._db.Log(`Fetched "${id}" from "${this.DatasetPath}".`);
33
32
  return item;
34
33
  }
35
34
  async FindOne(id) {
36
35
  this._db.Log(`Searching for "${id}"...`);
37
36
  const queryResult = await this._db.Send(new FindQuery(id, this._db.DatabaseDir));
38
37
  if (!queryResult.IsSuccess) {
39
- this._db.Log(`Not found "${id}".`);
40
- return null;
38
+ throw new Error(`Could not find "${id}" in "${this.DatasetPath}": ${queryResult.ErrorMessage}`);
41
39
  }
42
- this._db.Log(`Found "${id}".`);
43
40
  const rawItem = queryResult.Result;
44
41
  const item = this._converter.FromRaw(rawItem);
42
+ this._db.Log(`Found "${id}" in "${this.DatasetPath}".`);
45
43
  return item;
46
44
  }
47
45
  async GetAll() {
48
46
  this._db.Log(`Fetching all from "${this.DatasetPath}"...`);
49
47
  const queryResult = await this._db.Send(new ListQuery(this._db.DatabaseDir, this.dataset));
50
48
  if (!queryResult.IsSuccess) {
51
- this._db.Log(`Could not fetch items from "${this.DatasetPath}": ${queryResult.ErrorMessage}`);
52
- return [];
49
+ throw new Error(`Could not fetch items from "${this.DatasetPath}": ${queryResult.ErrorMessage}`);
53
50
  }
54
51
  const rawItems = queryResult.Result;
55
52
  const items = rawItems.map((raw) => this._converter.FromRaw(raw));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tblabs/storage",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "online storage module with auth",
5
5
  "license": "beerware",
6
6
  "main": "index.js",
Binary file
Binary file