Skip to content

Commit 0cf910b

Browse files
committed
fix: support abstract base entities
1 parent c443362 commit 0cf910b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Diff for: __tests__/soft-delete.spec.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,23 @@ class UserDeletedAt extends BaseEntity {
2020
deletedAt?: Date;
2121
}
2222

23-
@SoftDeletable(() => UserIsDeleted, "isDeleted", () => true, false)
23+
@SoftDeletable(() => SoftDeletableBaseEntity, "isDeleted", () => true, false)
2424
@Entity()
25-
class UserIsDeleted extends BaseEntity {
25+
abstract class SoftDeletableBaseEntity extends BaseEntity {
26+
constructor(_a: string) {
27+
super();
28+
}
29+
2630
@PrimaryKey()
2731
id!: number;
2832

2933
@Property()
3034
isDeleted!: boolean;
3135
}
3236

37+
@Entity()
38+
class UserIsDeleted extends SoftDeletableBaseEntity {}
39+
3340
@SoftDeletable({
3441
type: () => UserIsDeleted,
3542
field: "isDeleted",

Diff for: src/decorator.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ import {
88
SoftDeletableConfig,
99
} from "./common";
1010

11-
interface Type<T> {
12-
new (...args: any[]): T;
13-
prototype: T;
14-
}
11+
type Type<Entity> = abstract new (...args: any[]) => Entity;
1512

1613
type EntityDecorator<Entity> = (type: Type<Entity>) => void;
1714

0 commit comments

Comments
 (0)