Commit 6affab55 authored by “Yevgeniy's avatar “Yevgeniy

#36 make minor changes cascade porperty in related models

parent 0869aff6
......@@ -68,7 +68,7 @@ import {
@OneToMany(() => Task, (task: { project: Project; })=>task.project,{eager : true})
tasks!:Task[]|null;
@ManyToMany(() => User, (user: { projects: Project[]; }) => user.projects,{eager : true})
@ManyToMany(() => User, (user: { projects: Project[]; }) => user.projects,{eager : true,cascade: true, onUpdate:'CASCADE',onDelete: 'CASCADE'})
@JoinTable()
workers!: User[];
}
\ No newline at end of file
......@@ -25,7 +25,7 @@ import {
priority: priorityType | null;
author: User;
project:Project|null;
executors:User[]
executors:User[];
}
@Entity({ name: 'Task' })
......@@ -64,13 +64,10 @@ import {
@ManyToOne(() => User, (user: { tasks: Task[]; }) => user.tasks,{eager : true})
author!: User;
@ManyToMany(() => User,{eager : true})
@ManyToMany(() => User,{eager : true, cascade: true, onUpdate:'CASCADE',onDelete: 'CASCADE'})
@JoinTable()
executors!: User[];
@ManyToOne(()=>Project,(project:{tasks: Task[]}) => project.tasks)
project!: Project | null;
}
......@@ -97,7 +97,7 @@ router.put('/',async(req:Request, res:Response)=> {
.getOne()
if (!user) return res.status(404).send({Message:'user not found'})
const {id,title,description,project,dateTimeDue,dateTimeStart,accomplish,priority} = req.body;
const {id,title,description,project,dateTimeDue,dateTimeStart,accomplish,priority, executors} = req.body;
await dataSource
.createQueryBuilder()
.update(Task)
......@@ -105,11 +105,12 @@ router.put('/',async(req:Request, res:Response)=> {
title: title,
description: description,
project: project,
dateTimeDue: dateTimeDue,
dateTimeStart: dateTimeStart,
author:user,
dateTimeDue: dateTimeDue,
accomplish: accomplish,
priority: priority
priority: priority,
author:user,
executors:executors
})
.where("id = :id", { id: id })
.execute()
......
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