I have the following database structure: 2 table DB structure
The questions table is linked with the answers table through answers.questionId references questions.id.
The self-referenced table is referenced through answers.parentId references answers.id.
For example, I have the following data:
Questions table:
Answers table
Is it possible to get something like this (by querying with typeor):
[{id: 1, question: "What is my name?", answers: [{ value: "Man" }, { value: "Boss"}] },
{id: 2, question: "Where I am?", answers: [*{ value: "Country", answers: [{ value: "Ro" }, { value: "En" }] }*, {value:"Iland"}]
I want to have the answers self-referenced relations as well.
I tried this:
this.questionsRepo.find({
relations: ['answers'],
});
But obviously I get only the question and answer array
Is it possible to do something like that with an orm like TypeOrm?
Thanks for reading this!