Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
survey
Commits
77262376
Commit
77262376
authored
Aug 19, 2022
by
Yoon, Daeki
😅
Browse files
백엔드 설문 업데이트 로직 변경
parent
a32e85ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/db/survey.db.ts
View file @
77262376
...
@@ -46,7 +46,18 @@ export const getSurveys = async (userId: string) => {
...
@@ -46,7 +46,18 @@ export const getSurveys = async (userId: string) => {
};
};
export
const
updateSurvey
=
async
(
survey
:
HydratedDocument
<
ISurvey
>
)
=>
{
export
const
updateSurvey
=
async
(
survey
:
HydratedDocument
<
ISurvey
>
)
=>
{
const
newSurvey
=
await
Survey
.
findOneAndUpdate
({
_id
:
survey
.
_id
},
survey
);
console
.
log
(
"
update survey
"
,
survey
);
await
Promise
.
all
(
survey
.
questions
.
map
(
async
(
question
)
=>
await
Question
.
findOneAndUpdate
({
_id
:
question
.
_id
},
question
,
{
upsert
:
true
,
})
)
);
const
newSurvey
=
await
Survey
.
findOneAndUpdate
({
_id
:
survey
.
_id
},
survey
,
{
new
:
true
,
}).
populate
(
"
questions
"
);
return
newSurvey
;
return
newSurvey
;
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment