Commit 945f33fa authored by “Yevgeniy's avatar “Yevgeniy

#23 added onoToMany relation to Project for Task

parent 6d19d5d3
...@@ -5,9 +5,11 @@ import { ...@@ -5,9 +5,11 @@ import {
CreateDateColumn, CreateDateColumn,
BaseEntity, BaseEntity,
ManyToOne, ManyToOne,
ManyToMany ManyToMany,
OneToMany
} from 'typeorm'; } from 'typeorm';
import {User} from './User'; import {User} from './User';
import {Task} from './Task';
interface IProject{ interface IProject{
...@@ -15,7 +17,8 @@ import { ...@@ -15,7 +17,8 @@ import {
title: string; title: string;
color: string; color: string;
admin:User; admin:User;
workers:User[]| undefined; workers:User[];
tasks:Task[]|null;
createdAt: Date; createdAt: Date;
dateDue: Date| null; dateDue: Date| null;
department:boolean| false; department:boolean| false;
...@@ -43,7 +46,9 @@ import { ...@@ -43,7 +46,9 @@ import {
@ManyToOne(() => User, (user: { projects: Project[]; }) => user.projects) @ManyToOne(() => User, (user: { projects: Project[]; }) => user.projects)
admin!: User; admin!: User;
@ManyToMany(() => User, (user: { projects: Project[]; }) => user.projects) @ManyToMany(() => User, (user: { projects: Project[]; }) => user.projects)
workers!: User[]; workers!: User[];
@OneToMany(() => Task, (task: { project: Project; })=>task.project)
tasks!:Task[]|null;
} }
import express,{Router, Request, Response} from 'express';
import {User} from '../models/User';
import {myDataSource} from '../app-data-source';
import { nanoid } from 'nanoid';
const router:Router = express.Router();
const dataSource = myDataSource;
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