File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 11import { connectToDatabase } from "@/lib/database/mongoose" ;
2- import { Course } from "@/db/course" ;
32import { IRelatedSubject } from "@/interface" ;
43import { escapeRegExp } from "@/lib/utils/regex" ;
4+ import { Course } from "@/db/course" ;
55import RelatedSubject from "@/db/relatedSubjects" ;
66
77export async function getCourseList ( ) {
88 await connectToDatabase ( ) ;
99 return await Course . find ( ) . lean ( ) ;
1010}
11+
1112export async function getRelatedSubjects ( subject : string ) {
1213 await connectToDatabase ( ) ;
1314 const escapedSubject = escapeRegExp ( subject ) ;
1415 const subjects : IRelatedSubject [ ] = await RelatedSubject . find ( {
1516 subject : { $regex : new RegExp ( `${ escapedSubject } ` , "i" ) } ,
1617 } ) ;
1718
18- return subjects [ 0 ] ?. related_subjects ?? [ ] ;
19- }
19+ return subjects [ 0 ] ?. related_subjects || [ ] ;
20+ }
You can’t perform that action at this time.
0 commit comments