mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Saving data fix round 2
This commit is contained in:
parent
43734fb8f7
commit
1cf16dbafd
3 changed files with 8 additions and 30 deletions
|
@ -327,7 +327,6 @@ function addQuestion(data, subj, question) {
|
|||
assert(subj)
|
||||
assert(question)
|
||||
assert(typeof question === 'object')
|
||||
let result = []
|
||||
|
||||
var i = 0
|
||||
while (
|
||||
|
@ -341,20 +340,14 @@ function addQuestion(data, subj, question) {
|
|||
|
||||
if (i < data.length) {
|
||||
debugLog('Adding new question to existing subject', 'qdb add', 1)
|
||||
result = [...data]
|
||||
result[i].Questions = [...data[i].Questions, question]
|
||||
data[i].Questions.push(question)
|
||||
} else {
|
||||
debugLog('Creating new subject for question', 'qdb add', 1)
|
||||
result = [
|
||||
...data,
|
||||
{
|
||||
Name: subj,
|
||||
Questions: [question],
|
||||
},
|
||||
]
|
||||
data.push({
|
||||
Name: subj,
|
||||
Questions: [question],
|
||||
})
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
function searchData(data, question, subjName, questionData) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue