@wabot-dev/framework 0.0.50 → 0.1.0-beta-25
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/src/index.d.ts
CHANGED
|
@@ -775,6 +775,7 @@ declare class WhatsAppSenderByCloudApi extends WhatsAppSender {
|
|
|
775
775
|
|
|
776
776
|
interface ICrudRepository<T> {
|
|
777
777
|
find(id: string): Promise<T | null>;
|
|
778
|
+
findOrThrow(id: string): Promise<T>;
|
|
778
779
|
findAll(id: string): Promise<T[]>;
|
|
779
780
|
create(item: T): Promise<void>;
|
|
780
781
|
update(item: T): Promise<void>;
|
|
@@ -825,6 +826,7 @@ declare class PgCrudRepository<P extends Persistent> extends PgRepositoryBase<P>
|
|
|
825
826
|
protected readonly config: IPgRepositoryConfig<P>;
|
|
826
827
|
constructor(pool: Pool, config: IPgRepositoryConfig<P>);
|
|
827
828
|
find(id: string): Promise<P | null>;
|
|
829
|
+
findOrThrow(id: string): Promise<P>;
|
|
828
830
|
findAll(): Promise<P[]>;
|
|
829
831
|
create(item: P): Promise<void>;
|
|
830
832
|
update(item: P): Promise<void>;
|
|
@@ -17,6 +17,13 @@ class PgCrudRepository extends PgRepositoryBase {
|
|
|
17
17
|
const items = await this.query(sql, [id]);
|
|
18
18
|
return items.at(0) ?? null;
|
|
19
19
|
}
|
|
20
|
+
async findOrThrow(id) {
|
|
21
|
+
const item = await this.find(id);
|
|
22
|
+
if (!item) {
|
|
23
|
+
throw new Error(`Not found ${this.config.constructor.name} with id = '${id}'`);
|
|
24
|
+
}
|
|
25
|
+
return item;
|
|
26
|
+
}
|
|
20
27
|
async findAll() {
|
|
21
28
|
const sql = `
|
|
22
29
|
SELECT ${this.columns}
|