#68 added model DateTimeTask

parent fb898090
import {
Column,
Entity,
PrimaryGeneratedColumn,
CreateDateColumn,
BaseEntity,
ManyToOne,
} from 'typeorm';
import {Task} from './Task';
interface IDateTimeTask{
id: string;
createdAt: Date;
dateTimeStart: Date;
dateTimeDue: Date;
task: Task;
}
@Entity({name:"DateTimeTask"})
export class DateTimeTask extends BaseEntity implements IDateTimeTask{
@PrimaryGeneratedColumn("uuid")
id!: string;
@CreateDateColumn({ name: 'createdAt', type: Date, default: new Date() })
createdAt!: Date;
@CreateDateColumn({ name: 'createdAt', type: Date, nullable:false })
dateTimeStart!: Date;
@CreateDateColumn({ name: 'createdAt', type: Date, nullable:false })
dateTimeDue!: Date;
@ManyToOne(() => Task, (task: { dateTimeTasks: DateTimeTask[]; }) => task.dateTimeTasks,{cascade: true, onUpdate:'CASCADE',nullable:true})
task!: Task;
}
\ No newline at end of file
......@@ -5,9 +5,7 @@ import {
CreateDateColumn,
BaseEntity,
ManyToOne,
ManyToMany,
OneToMany,
JoinTable
} from 'typeorm';
import {User} from './User';
import {Project} from './Project';
......
......@@ -6,10 +6,12 @@ import {
BaseEntity,
ManyToOne,
OneToOne,
JoinTable
JoinTable,
OneToMany
} from 'typeorm';
import {User} from './User';
import {Project} from './Project';
import { DateTimeTask } from './DateTimeTask';
type taskFinishType = "opened" | "done" |"failed";
type priorityType = "A" | "B" |"C";
......@@ -27,6 +29,7 @@ import {
priority: priorityType | null;
author: User;
project:Project|null;
dateTimeTasks:DateTimeTask[]|null;
executor:User;
}
......@@ -76,4 +79,7 @@ import {
@ManyToOne(()=>Project,(project:{tasks: Task[]}) => project.tasks,{eager : true,nullable: true,onUpdate:'CASCADE'})
project!: Project;
@OneToMany(() => DateTimeTask, (dateTimeTask: { task: Task }) => dateTimeTask.task)
dateTimeTasks!: DateTimeTask[];
}
......@@ -37,7 +37,7 @@ interface IUser {
createdTasks:Task[];
// workerInProjects:Project[];
// adminInProjects:Project[];
membership: Member[];
members: Member[];
}
......@@ -88,7 +88,7 @@ export class User extends BaseEntity implements IUser {
@OneToMany(() => Member, (member: { user: User }) => member.user)
membership!: Member[];
members!: Member[];
// @ManyToMany(() => Project,(project: { user: User }) => project.user)
// @JoinTable()
......
import express,{Router, Request, Response} from 'express';
import {myDataSource} from '../app-data-source';
import { Member } from "../models/Member";
const router:Router = express.Router();
const dataSource = myDataSource;
......@@ -166,7 +166,7 @@ router.post('/remove-user', async (req: Request, res: Response):Promise<Response
.createQueryBuilder()
.select("user")
.from(User, "user")
.leftJoinAndSelect("user.membership","member")
.leftJoinAndSelect("user.members","member")
.leftJoinAndSelect('member.project', 'project' )
.where("user.token = :token", { token })
.andWhere('project.id=:projectId',{projectId})
......
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