-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsertQuiz.ts
More file actions
127 lines (126 loc) · 3.38 KB
/
insertQuiz.ts
File metadata and controls
127 lines (126 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import mongoose from 'mongoose';
import { MONGO_URI } from '../db.ts';
import { Quiz } from '../model/quiz.ts';
import { v4 } from 'uuid';
const insertQuiz = async () => {
try {
await mongoose.connect(MONGO_URI);
console.log('mongodb성공');
const quizzes = [
{
title: '첫 번째 퀴즈',
description: '목표 지점까지 이동한 후 공격하세요.',
grid: [
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[2, 0, 0, 0],
],
hint: '첫번쨰 힌트',
startPosition: { x: 0, y: 0 },
goalPosition: { x: 0, y: 3 },
goalAction: 'shoot',
commands: [
{
name: 'forward',
functionCode: "console.log('move forward');",
},
{
name: 'shoot',
functionCode: "console.log('shoot');",
},
],
},
{
title: '두 번째 퀴즈',
description: '목표 지점까지 이동한 후 공격하세요.',
grid: [
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 2],
],
hint: '두번쨰 힌트 방향을 바꿀수 있어요~',
startPosition: { x: 0, y: 0 },
goalPosition: { x: 3, y: 3 },
goalAction: 'shoot',
commands: [
{
name: 'forward',
functionCode: "console.log('move forward');",
},
{
name: 'shoot',
functionCode: "console.log('shoot');",
},
{
name: 'turnRight',
functionCode: "console.log('turnRight');",
},
],
},
{
title: '세 번째 퀴즈',
description: '목표 지점까지 이동한 후 공격하세요.',
grid: [
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[2, 0, 0, 0],
],
hint: '세번쨰 힌트',
startPosition: { x: 0, y: 0 },
goalPosition: { x: 2, y: 0 },
goalAction: 'shoot',
commands: [
{
name: 'forward',
functionCode: "console.log('move forward');",
},
{
name: 'shoot',
functionCode: "console.log('shoot');",
},
],
},
{
title: '네 번째 퀴즈',
description: '목표 지점까지 이동한 후 공격하세요.',
grid: [
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[2, 0, 0, 0],
],
hint: '네번쨰 힌트',
startPosition: { x: 0, y: 0 },
goalPosition: { x: 2, y: 0 },
goalAction: 'shoot',
commands: [
{
name: 'forward',
functionCode: "console.log('move forward');",
},
{
name: 'shoot',
functionCode: "console.log('shoot');",
},
],
},
];
const quizUUID = quizzes.map(() => v4());
const quizzesLinkedList = quizzes.map((quiz, index) => ({
...quiz,
id: quizUUID[index],
isFirst: index === 0,
prevId: index === 0 ? null : quizUUID[index - 1],
nextId: index === quizUUID.length - 1 ? null : quizUUID[index + 1],
}));
await Quiz.insertMany(quizzesLinkedList);
process.exit(0);
} catch (error) {
console.error('오류 발생:', error);
process.exit(1);
}
};
insertQuiz();