In developing a small API with Express and TypeScript, I am faced with handling both POST and GET requests. The POST request involves receiving a list of organizations, which may have daughter organizations that can also have their own daughters, creating a complex hierarchical structure.
One approach I am considering is setting up two database tables in postgreSQL: Organization and Parent_child.
Organization{
id: number,
name: string
}
Parent_child{
parent_id: number,
child_id: number
}
My goal is to establish a many-to-many relationship between Organization entities through the Parent_child table. Although I have tried exploring various resources on how to manipulate databases, most tutorials lack clarity.
Do you have any recommendations or suggestions on how to achieve this kind of relationship? I have come across sequelize and typeORM as potential solutions, but their documentation has been confusing for me so far.