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

#36 make minor changes cascade porperty in related models

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