-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c77d778
commit 8d40636
Showing
46 changed files
with
4,343 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="start - auth" type="js.build_tools.npm"> | ||
<package-json value="$PROJECT_DIR$/examples/package.json" /> | ||
<command value="run" /> | ||
<scripts> | ||
<script value="start" /> | ||
</scripts> | ||
<arguments value="-- auth" /> | ||
<node-interpreter value="project" /> | ||
<envs /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Connection } from 'typeorm'; | ||
import { SubTaskEntity } from '../src/sub-task/sub-task.entity'; | ||
import { TagEntity } from '../src/tag/tag.entity'; | ||
import { TodoItemEntity } from '../src/todo-item/todo-item.entity'; | ||
import { executeTruncate } from '../../helpers'; | ||
import { UserEntity } from '../src/user/user.entity'; | ||
|
||
const tables = ['todo_item', 'sub_task', 'tag', 'user']; | ||
export const truncate = async (connection: Connection): Promise<void> => executeTruncate(connection, tables); | ||
|
||
export const refresh = async (connection: Connection): Promise<void> => { | ||
await truncate(connection); | ||
|
||
const userRepo = connection.getRepository(UserEntity); | ||
const todoRepo = connection.getRepository(TodoItemEntity); | ||
const subTaskRepo = connection.getRepository(SubTaskEntity); | ||
const tagsRepo = connection.getRepository(TagEntity); | ||
|
||
const users = await userRepo.save([ | ||
{ username: 'nestjs-query', password: '123' }, | ||
{ username: 'nestjs-query-2', password: '123' }, | ||
{ username: 'nestjs-query-3', password: '123' }, | ||
]); | ||
|
||
const urgentTag = await tagsRepo.save({ name: 'Urgent' }); | ||
const homeTag = await tagsRepo.save({ name: 'Home' }); | ||
const workTag = await tagsRepo.save({ name: 'Work' }); | ||
const questionTag = await tagsRepo.save({ name: 'Question' }); | ||
const blockedTag = await tagsRepo.save({ name: 'Blocked' }); | ||
|
||
const todoItems: TodoItemEntity[] = await users.reduce(async (prev, user) => { | ||
const allTodos = await prev; | ||
const userTodos = await todoRepo.save([ | ||
{ title: 'Create Nest App', completed: true, priority: 0, tags: [urgentTag, homeTag], owner: user }, | ||
{ title: 'Create Entity', completed: false, priority: 1, tags: [urgentTag, workTag], owner: user }, | ||
{ title: 'Create Entity Service', completed: false, priority: 2, tags: [blockedTag, workTag], owner: user }, | ||
{ title: 'Add Todo Item Resolver', completed: false, priority: 3, tags: [blockedTag, homeTag], owner: user }, | ||
{ | ||
title: 'How to create item With Sub Tasks', | ||
completed: false, | ||
priority: 4, | ||
tags: [questionTag, blockedTag], | ||
owner: user, | ||
}, | ||
]); | ||
return [...allTodos, ...userTodos]; | ||
}, Promise.resolve([] as TodoItemEntity[])); | ||
|
||
await subTaskRepo.save( | ||
todoItems.reduce((subTasks, todo) => { | ||
return [ | ||
...subTasks, | ||
{ completed: true, title: `${todo.title} - Sub Task 1`, todoItem: todo }, | ||
{ completed: false, title: `${todo.title} - Sub Task 2`, todoItem: todo }, | ||
{ completed: false, title: `${todo.title} - Sub Task 3`, todoItem: todo }, | ||
]; | ||
}, [] as Partial<SubTaskEntity>[]), | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
export const todoItemFields = ` | ||
id | ||
title | ||
completed | ||
description | ||
age | ||
`; | ||
|
||
export const subTaskFields = ` | ||
id | ||
title | ||
description | ||
completed | ||
todoItemId | ||
`; | ||
|
||
export const tagFields = ` | ||
id | ||
name | ||
`; | ||
|
||
export const pageInfoField = ` | ||
pageInfo{ | ||
hasNextPage | ||
hasPreviousPage | ||
startCursor | ||
endCursor | ||
} | ||
`; | ||
|
||
export const edgeNodes = (fields: string): string => { | ||
return ` | ||
edges { | ||
node{ | ||
${fields} | ||
} | ||
cursor | ||
} | ||
`; | ||
}; | ||
|
||
export const todoItemAggregateFields = ` | ||
count { | ||
id | ||
title | ||
description | ||
completed | ||
created | ||
updated | ||
} | ||
sum { | ||
id | ||
} | ||
avg { | ||
id | ||
} | ||
min { | ||
id | ||
title | ||
description | ||
} | ||
max { | ||
id | ||
title | ||
description | ||
} | ||
`; | ||
|
||
export const tagAggregateFields = ` | ||
count { | ||
id | ||
name | ||
created | ||
updated | ||
} | ||
sum { | ||
id | ||
} | ||
avg { | ||
id | ||
} | ||
min { | ||
id | ||
name | ||
} | ||
max { | ||
id | ||
name | ||
} | ||
`; | ||
|
||
export const subTaskAggregateFields = ` | ||
count { | ||
id | ||
title | ||
description | ||
completed | ||
todoItemId | ||
} | ||
sum { | ||
id | ||
} | ||
avg { | ||
id | ||
} | ||
min { | ||
id | ||
title | ||
description | ||
todoItemId | ||
} | ||
max { | ||
id | ||
title | ||
description | ||
todoItemId | ||
} | ||
`; |
Oops, something went wrong.