|
1 | 1 | import { Connection } from 'typeorm';
|
2 |
| -import { SubTaskEntity } from '../src/sub-task/sub-task.entity'; |
3 |
| -import { TagEntity } from '../src/tag/tag.entity'; |
4 |
| -import { TodoItemEntity } from '../src/todo-item/todo-item.entity'; |
5 | 2 | import { executeTruncate } from '../../helpers';
|
| 3 | +import { TodoItemEntity } from '../src/todo-item/todo-item.entity'; |
6 | 4 |
|
7 |
| -const tables = ['todo_item', 'sub_task', 'tag']; |
| 5 | +const tables = ['todo_item']; |
8 | 6 | export const truncate = async (connection: Connection): Promise<void> => executeTruncate(connection, tables);
|
9 | 7 |
|
10 | 8 | export const refresh = async (connection: Connection): Promise<void> => {
|
11 | 9 | await truncate(connection);
|
12 | 10 |
|
13 | 11 | const todoRepo = connection.getRepository(TodoItemEntity);
|
14 |
| - const subTaskRepo = connection.getRepository(SubTaskEntity); |
15 |
| - const tagsRepo = connection.getRepository(TagEntity); |
16 | 12 |
|
17 |
| - const urgentTag = await tagsRepo.save({ name: 'Urgent' }); |
18 |
| - const homeTag = await tagsRepo.save({ name: 'Home' }); |
19 |
| - const workTag = await tagsRepo.save({ name: 'Work' }); |
20 |
| - const questionTag = await tagsRepo.save({ name: 'Question' }); |
21 |
| - const blockedTag = await tagsRepo.save({ name: 'Blocked' }); |
22 |
| - |
23 |
| - const todoItems = await todoRepo.save([ |
24 |
| - { title: 'Create Nest App', completed: true, tags: [urgentTag, homeTag] }, |
25 |
| - { title: 'Create Entity', completed: false, tags: [urgentTag, workTag] }, |
26 |
| - { title: 'Create Entity Service', completed: false, tags: [blockedTag, workTag] }, |
27 |
| - { title: 'Add Todo Item Resolver', completed: false, tags: [blockedTag, homeTag] }, |
| 13 | + await todoRepo.save([ |
| 14 | + { title: 'Create Nest App', completed: true }, |
| 15 | + { title: 'Create Entity', completed: false }, |
| 16 | + { title: 'Create Entity Service', completed: false }, |
| 17 | + { title: 'Add Todo Item Resolver', completed: false }, |
28 | 18 | {
|
29 | 19 | title: 'How to create item With Sub Tasks',
|
30 | 20 | completed: false,
|
31 |
| - tags: [questionTag, blockedTag], |
32 | 21 | },
|
33 | 22 | ]);
|
34 |
| - |
35 |
| - await subTaskRepo.save( |
36 |
| - todoItems.reduce((subTasks, todo) => { |
37 |
| - return [ |
38 |
| - ...subTasks, |
39 |
| - { completed: true, title: `${todo.title} - Sub Task 1`, todoItem: todo }, |
40 |
| - { completed: false, title: `${todo.title} - Sub Task 2`, todoItem: todo }, |
41 |
| - { completed: false, title: `${todo.title} - Sub Task 3`, todoItem: todo }, |
42 |
| - ]; |
43 |
| - }, [] as Partial<SubTaskEntity>[]), |
44 |
| - ); |
45 | 23 | };
|
0 commit comments