initial commit, lots of random shit
This commit is contained in:
commit
7bb18f0a71
27 changed files with 3394 additions and 0 deletions
29
src/lib/server/entity/Edge.ts
Normal file
29
src/lib/server/entity/Edge.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import {BeforeInsert, Entity, ManyToOne, PrimaryColumn} from 'typeorm';
|
||||
|
||||
import {Node} from '$lib/server/entity/Node';
|
||||
import {ulidMonotonic} from '$lib/server/ulid';
|
||||
|
||||
@Entity()
|
||||
export class Edge {
|
||||
@PrimaryColumn({type: 'varchar', length: 26})
|
||||
id = ulidMonotonic();
|
||||
|
||||
@ManyToOne(() => Node, node => node.outgoingEdges, {
|
||||
nullable: false,
|
||||
cascade: true,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
head!: Node;
|
||||
|
||||
@ManyToOne(() => Node, node => node.incomingEdges, {
|
||||
nullable: false,
|
||||
cascade: true,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
tail!: Node;
|
||||
|
||||
@BeforeInsert()
|
||||
beforeInsert () {
|
||||
this.id = ulidMonotonic();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue