import { DataSource, Repository } from 'typeorm';
import { CourseList } from 'src/online-course/entities/course-manage/course-list.entity';
export async function handler(dataSource: DataSource, { user }) {
  const c = dataSource.manager
    .createQueryBuilder(CourseList, 'cl')
    .select(['cl.id ', 'cl.name as title'])
    .where({ creator: user.userId });
  const data1 = await c.getRawMany();
  const data2 = await c.getCount();
  return {
    data: data1,
    total: data2,
  };
}
