I have a table called pathway
, pathway_courses
, and courses
. The idea is, each pathway has certain number of courses. pathway_courses
is the join table joining pathway
table from id
to courses
table. Basically,
pathway (id) --> pathway_courses(pathway_id) <--> pathway_courses(course_id) <-- courses(id)
I am using ObjectionJS ORM and used ManyToMany relation mapping.
And this is my response when I try to fetch data.
"courses": {
"id": 1,
"code": "FRTEND",
"name": "Front-End",
"description": "Learn Front End Development",
"created_at": "2020-09-18T12:36:33.299Z",
"tracking_enabled": true,
"tracking_frequency": "weekly",
"tracking_day_of_week": 2,
"tracking_days_lock_before_cycle": 7,
"courses": [
{
"id": "60",
"type": "html",
"name": "Let's talk Technology - SV201",
"logo": null,
"notes": null,
"days_to_complete": "30",
"short_description": "Let's talk on various technology topics to improve our understanding of Technology as well as English",
"sequence_num": "20",
"created_at": "2020-09-20T19:23:15.991Z"
},
{
"id": "59",
"type": "html",
"name": "Kuch Baatein (Samvaad) - SV101",
"logo": null,
"notes": null,
"days_to_complete": "30",
"short_description": "Let's start talking in English with the help of these very simple topics",
"sequence_num": "19",
"created_at": "2020-09-20T19:23:15.991Z"
},
{
"id": "61",
"type": "html",
"name": "Let's talk Technology (Samvaad) - SV301",
"logo": null,
"notes": null,
"days_to_complete": "30",
"short_description": "Let's talk on various technology topics to improve our understanding of Technology as well as English",
"sequence_num": "22",
"created_at": "2020-09-20T19:23:15.991Z"
},
{
"id": "33",
"type": "html",
"name": "Hackathon - Dry Run on a Dry Day",
"logo": null,
"notes": null,
"days_to_complete": "45",
"short_description": "Isse aap program ka dry run ke through program ka control flow bananana seekhoge.",
"sequence_num": "0",
"created_at": "2020-09-20T19:23:15.991Z"
}
]
}
}
But the order in which I get the courses is not correct.
How do I solve this. How can I get the courses in the same order as in my table?