-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #332 from privacy-scaling-explorations/feat/many-t…
…o-many-group-member Add many to many relationship between group and member
- Loading branch information
Showing
4 changed files
with
196 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,11 @@ | ||
import { | ||
CreateDateColumn, | ||
Entity, | ||
ManyToOne, | ||
Column, | ||
Index, | ||
Unique, | ||
JoinColumn | ||
} from "typeorm" | ||
|
||
import { Group } from "./group.entity" | ||
import { CreateDateColumn, Entity, Index, PrimaryColumn } from "typeorm" | ||
|
||
@Entity("members") | ||
@Unique(["id", "group"]) | ||
@Index(["id", "group"]) | ||
export class Member { | ||
@Column({ primary: true, unique: false }) | ||
@PrimaryColumn() | ||
@Index({ unique: true }) | ||
id: string | ||
|
||
// In reality the relation group -> members is many-to-many. | ||
// i.e we allow same member id to be part of many groups. | ||
// But since this property is not used in any feature at the moment, | ||
// it is treated as many-to-one in the code for simplicity. | ||
@ManyToOne(() => Group, (group) => group.members, { | ||
onDelete: "CASCADE" | ||
}) | ||
@JoinColumn({ name: "group_id" }) | ||
group: Group | ||
|
||
@CreateDateColumn({ name: "created_at" }) | ||
createdAt: Date | ||
} |
Oops, something went wrong.