-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifest.js
executable file
·58 lines (51 loc) · 1.54 KB
/
manifest.js
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
const sqlite3 = require('sqlite3');
const { open } = require('sqlite')
// async function destinySeasonDefinition() {
// try {
// sqlite3.verbose()
// const db = await dbConnect()
// const results = await getSeasonDefinitions(db)
// } catch(err){
// console.log(err)
// }
// }
async function getTableData(table) {
try {
sqlite3.verbose()
const db = await dbConnect()
const SQL = `SELECT * FROM ${table}`
const rows = await db.all(SQL)
return rows
} catch(err) {
console.error(err)
throw err
}
}
// async function getSeasonDefinitions(db) {
// const results = []
// try {
// const SQL = "SELECT * FROM DestinySeasonDefinition"
// const row = await db.all(SQL)
// // console.log(Object.keys(row[0].json))
// // console.log(JSON.parse(row[0].json))
// row.forEach(element => {
// // console.log(element.id, element.name)
// results.push(JSON.parse(element.json))
// // console.log(data.seasonNumber, data.displayProperties.name)
// });
// results.sort((a, b) => { return (a.seasonNumber < b.seasonNumber) ? -1 : ((a.seasonNumber > b.seasonNumber) ? 1 : 0)})
// results.forEach(item => console.log(item.seasonNumber, item.displayProperties.name, item.displayProperties.name))
// } catch(err) {
// console.error(err)
// throw err
// }
// }
function dbConnect() {
return open({
filename: './data/responses/Manifest.content',
driver: sqlite3.Database
})
}
module.exports = {
getTableData
}