saving data
This commit is contained in:
@@ -46,10 +46,37 @@ export default class Database {
|
||||
} catch(e) {
|
||||
throw e
|
||||
}
|
||||
|
||||
}
|
||||
this.saveData()
|
||||
}
|
||||
|
||||
saveData() {
|
||||
|
||||
async saveData() {
|
||||
let data = {
|
||||
"nodes": {
|
||||
|
||||
},
|
||||
"edges": {
|
||||
|
||||
}
|
||||
}
|
||||
let arrs = [
|
||||
this.titles.entries,
|
||||
this.members.entries,
|
||||
this.tokens.entries
|
||||
]
|
||||
let ids = [
|
||||
Object.entries(this.titles.ids),
|
||||
Object.entries(this.members.ids),
|
||||
Object.entries(this.tokens.ids),
|
||||
]
|
||||
for(let i=0; i<arrs.length; i++) {
|
||||
let arr = arrs[i]
|
||||
for(let j=0; j<arr.length; j++) {
|
||||
data.nodes[ids[i][j][0]] = arr[j]
|
||||
}
|
||||
}
|
||||
|
||||
await fs.writeFile(path.join(process.cwd(), 'db/db.json'), JSON.stringify(data, null, 4), "utf8");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user