Interested in my tech stack: express + typeorm + mysql
Seeking a solution for the following task: I have a csv file with over 100000 rows, where each row contains data such as:
reviewer, review, email, rating, employee, employee_position, employee_unique_id, company, company_description
I aim to efficiently store all this data in 5 distinct tables
@Entity('user')
export class UserEntity {
@PrimaryGeneratedColumn('uuid')
id: number
@Column()
name: string
@Column()
email: string
@OneToMany(() => ReviewEntity, review => review.fromUser)
reviews: ReviewEntity[]
}
@Entity('review')
export class ReviewEntity {
@PrimaryGeneratedColumn()
id: number
@Column('longtext')
text: string
@Column()
rating: number
@ManyToOne(() => UserEntity, user => user.reviews)
fromUser: UserEntity
@ManyToOne(() => EmployeeEntity, employee => employee.reviews)
forEmployee: EmployeeEntity
}
@Entity('employee')
export class EmployeeEntity {
@PrimaryColumn()
id: string
@Column()
name: string
@ManyToOne(() => EmployeePositionEntity, position => position.employees)
position: EmployeePositionEntity
@ManyToOne(() => CompanyEntity, company => company.employees)
company: CompanyEntity
@OneToMany(() => ReviewEntity, review => review.forEmployee)
reviews: ReviewEntity[]
}
@Entity('employee_position')
export class EmployeePositionEntity {
@PrimaryGeneratedColumn()
id: number
@Column()
name: string
@OneToMany(() => EmployeeEntity, employee => employee.position)
employees: EmployeeEntity[]
}
@Entity('company')
export class CompanyEntity {
@PrimaryGeneratedColumn()
id: number
@Column()
name: string
@Column('longtext')
description: string
@OneToMany(() => EmployeeEntity, employee => employee.company)
employees: EmployeeEntity[]
}
I attempted to parse the data into 5 arrays and save them concurrently in batches of 100 items each, but the process was too time-consuming