generated from nestjs/typescript-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbase.ports.ts
39 lines (33 loc) · 973 Bytes
/
base.ports.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { Base } from './base.entity';
export interface GetByIdPort<T extends Base> {
getById(id: T['id']): Promise<T | undefined>;
}
export interface GetAllPort<T extends Base> {
getAll(): Promise<T[]>;
}
export interface UpdatePort<T extends Base> {
update(entityId: T['id'], properties: Partial<T>): Promise<T | undefined>;
}
export interface CreatePort<T extends Base> {
create(properties: Partial<T>): Promise<T>;
}
export interface DeletePort<T extends Base> {
delete(id: T['id']): Promise<void>;
}
export abstract class BasePorts<T extends Base>
implements
GetByIdPort<T>,
GetAllPort<T>,
CreatePort<T>,
UpdatePort<T>,
DeletePort<T>
{
abstract getById(id: T['id']): Promise<T | undefined>;
abstract getAll(): Promise<T[]>;
abstract create(properties: Partial<T>): Promise<T>;
abstract update(
entityId: T['id'],
properties: Partial<T>,
): Promise<T | undefined>;
abstract delete(id: T['id']): Promise<void>;
}