Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the data models #46

Merged
merged 9 commits into from
Aug 11, 2023
Merged

Conversation

kumuditha-udayanga
Copy link
Member

Purpose

The purpose of this PR is to fix #8

Goals

Approach

Screenshots

Checklist

  • This PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.
  • I have read and understood the development best practices guidelines ( http://bit.ly/sef-best-practices )
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Related PRs

Test environment

Learning

content: string
// Should be ENUM
@Column()
state: string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's create an enum type


@UpdateDateColumn()
updated_at: Date | undefined

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mente, mentor relationship

 @ManyToOne(() => Mentor, mentor => mentor.mentees)
  mentor: Mentor;


@UpdateDateColumn()
updated_at: Date | undefined

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OneToMany(() => Mentee, mentee => mentee.mentor)
  mentees: Mentee[];

state: string
// Should be Enum
@Column()
category: string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a string

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this has a relationship. one to many with category

@anjula-sack
Copy link
Member

can you add the program entity as well @kumuditha-udayanga


@Entity('mentee')
class Mentee {
@PrimaryGeneratedColumn()
id!: bigint

@Column({type: "enum"})
@Column()
state: string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a enum. PENDING, REJECTED, ACCEPTED

state: string
// Should be Enum
@Column()
category: string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this has a relationship. one to many with category

src/entity/platform.entity.ts Outdated Show resolved Hide resolved
src/enums/enums.ts Outdated Show resolved Hide resolved
category: string,
) {
this.category = category;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}
@BeforeInsert()
@BeforeUpdate()
updateTimestamps() {
this.updated_at = new Date();
if (!this.uuid) {
this.created_at = new Date();
}
}
@BeforeInsert()
async generateUuid() {
if (!this.uuid) {
this.uuid = uuidv4();
}
}

@Entity("category")
class Category {
@PrimaryGeneratedColumn('uuid')
id!: bigint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
id!: bigint
uuid!: bigint
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
created_at: Date | undefined;
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
updated_at: Date | undefined;

@Entity("email")
class Email {
@PrimaryGeneratedColumn('uuid')
id!: bigint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
id!: bigint
uuid!: bigint

Comment on lines 26 to 27
@CreateDateColumn()
created_at: Date | undefined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@CreateDateColumn()
created_at: Date | undefined
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
created_at: Date | undefined;
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
updated_at: Date | undefined;

this.subject = subject;
this.content = content;
this.state = state;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}
@BeforeInsert()
@BeforeUpdate()
updateTimestamps() {
this.updated_at = new Date();
if (!this.uuid) {
this.created_at = new Date();
}
}
@BeforeInsert()
async generateUuid() {
if (!this.uuid) {
this.uuid = uuidv4();
}
}

@Entity('mentee')
class Mentee {
@PrimaryGeneratedColumn()
id!: bigint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
id!: bigint
uuid!: bigint

@Entity("mentor")
class Mentor {
@PrimaryGeneratedColumn('uuid')
id!: bigint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
id!: bigint
uuid!: bigint

Comment on lines 39 to 43
@CreateDateColumn()
created_at: Date | undefined

@UpdateDateColumn()
updated_at: Date | undefined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this just like above,

refer to the existing profile entity

@Entity("platform")
class Platform {
@PrimaryGeneratedColumn('uuid')
id!: bigint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
id!: bigint
uuid!: bigint

@@ -0,0 +1,16 @@
interface Option {
// todo: To be determined
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

@anjula-sack
Copy link
Member

@kumuditha-udayanga can you fix the conflicts?

@kumuditha-udayanga
Copy link
Member Author

Sure @anjula-sack, I'll resolve them as well.

@anjula-sack
Copy link
Member

Hi @kumuditha-udayanga, any updates on this?

Copy link
Member

@anjula-sack anjula-sack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! @kumuditha-udayanga

@anjula-sack anjula-sack merged commit 21127a7 into sef-global:main Aug 11, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement the data models
2 participants