mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Added db checker
This commit is contained in:
parent
595d4e02e0
commit
9bd0236326
1 changed files with 64 additions and 0 deletions
64
utils/dbcheck.js
Normal file
64
utils/dbcheck.js
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Question Server question file merger
|
||||||
|
GitLab: <https://gitlab.com/MrFry/mrfrys-node-server>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
const utils = require('./utils.js')
|
||||||
|
|
||||||
|
Main()
|
||||||
|
|
||||||
|
function Main () {
|
||||||
|
console.clear()
|
||||||
|
const params = GetParams()
|
||||||
|
console.log(params)
|
||||||
|
var db = []
|
||||||
|
let errors = 0
|
||||||
|
|
||||||
|
PrintLN()
|
||||||
|
console.log(params[0] + ': ')
|
||||||
|
try {
|
||||||
|
db = JSON.parse(utils.ReadFile(params[0]))
|
||||||
|
db.Subjects.forEach((subj) => {
|
||||||
|
subj.Questions.forEach((question) => {
|
||||||
|
if (question.I) {
|
||||||
|
console.log('gebasz')
|
||||||
|
console.log(subj.Name)
|
||||||
|
console.log(question)
|
||||||
|
PrintLN()
|
||||||
|
errors++
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
PrintLN()
|
||||||
|
console.log(`done, ${errors} error`)
|
||||||
|
|
||||||
|
// utils.WriteFile(JSON.stringify(db), 'newData')
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function PrintLN () {
|
||||||
|
console.log('------------------------------------------------------')
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetParams () {
|
||||||
|
return process.argv.splice(2)
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue