#63 added router/projects/my

parent 53e17d6e
...@@ -5,7 +5,6 @@ import { User } from '../models/User'; ...@@ -5,7 +5,6 @@ import { User } from '../models/User';
import { Member, MemberRole } from '../models/Member'; import { Member, MemberRole } from '../models/Member';
import { userInfo } from 'os'; import { userInfo } from 'os';
import { Task } from '../models/Task'; import { Task } from '../models/Task';
import { getRepository } from 'typeorm';
const router:Router = express.Router(); const router:Router = express.Router();
const dataSource = myDataSource; const dataSource = myDataSource;
...@@ -26,7 +25,22 @@ router.get('/my',async (req:Request, res:Response): Promise<Response>=> { ...@@ -26,7 +25,22 @@ router.get('/my',async (req:Request, res:Response): Promise<Response>=> {
.getOne(); .getOne();
if(!user) return res.status(404).send({Message:'user not found'}) if(!user) return res.status(404).send({Message:'user not found'})
const projects:Project[] = await dataSource.manager.find(Project)
const projects = await dataSource
.createQueryBuilder()
.from(Project, "project")
.select("project")
.leftJoinAndSelect('project.members', 'member')
.loadRelationCountAndMap('project.tasks', 'project.tasks')
.leftJoinAndSelect('member.user', 'user' )
.addSelect('member')
.where('member.userId = :userId',{userId:user.id})
// .where("project.id = :id", { id: req.params.id })
// .select(["*","members"])
// .select("*")
.getMany()
// const projects:Project[] = await dataSource.manager.find(Project)
return res.send({projects}) return res.send({projects})
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment