Skip to content

Commit a13d20a

Browse files
committed
feat(projection-typeorm): extend HandleEntity to take parentHandle and subhandles
1 parent 5f42691 commit a13d20a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/projection-typeorm/src/entity/Handle.entity.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AssetEntity } from './Asset.entity';
22
import { Cardano, Handle } from '@cardano-sdk/core';
3-
import { Column, Entity, JoinColumn, OneToOne, PrimaryColumn } from 'typeorm';
3+
import { Column, Entity, JoinColumn, OneToMany, OneToOne, PrimaryColumn } from 'typeorm';
44

55
@Entity()
66
export class HandleEntity {
@@ -21,4 +21,9 @@ export class HandleEntity {
2121
@Column('varchar', { nullable: true })
2222
/** `null` when cardanoAddress === `null` */
2323
defaultForPaymentCredential?: Handle | null;
24+
@OneToOne(() => HandleEntity, { nullable: true, onDelete: 'CASCADE' })
25+
@JoinColumn()
26+
parentHandle?: HandleEntity;
27+
@OneToMany(() => HandleEntity, (handle) => handle.parentHandle)
28+
subHandles?: HandleEntity[];
2429
}

0 commit comments

Comments
 (0)