1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-07 10:38:54 +08:00

Pivot implementation and redesign (#69)

- Pivot support implementation 
- Rename queries into inquiries
- Rename editor into workspace
- Change result set format
- New JSON format for inquiries
- Redesign panels
This commit is contained in:
lana-k
2021-08-04 22:20:51 +02:00
committed by GitHub
parent 8d0bc6affe
commit 5017b55944
105 changed files with 4659 additions and 2021 deletions

View File

@@ -1,13 +1,17 @@
import sqliteParser from 'sqlite-parser'
export default {
* generateChunks (arr, size) {
const count = Math.ceil(arr.length / size)
* generateChunks (data, size) {
const matrix = Object.keys(data).map(col => data[col])
const [row] = matrix
const transposedMatrix = row.map((value, column) => matrix.map(row => row[column]))
const count = Math.ceil(transposedMatrix.length / size)
for (let i = 0; i <= count - 1; i++) {
const start = size * i
const end = start + size
yield arr.slice(start, end)
yield transposedMatrix.slice(start, end)
}
},
@@ -17,11 +21,11 @@ export default {
return `INSERT INTO "${tabName}" (${colList}) VALUES (${params});`
},
getCreateStatement (tabName, columns, values) {
getCreateStatement (tabName, data) {
let result = `CREATE table "${tabName}"(`
columns.forEach((col, index) => {
// Get the first row of values to determine types
const value = values[0][index]
for (const col in data) {
// Get the first row of values to determine types
const value = data[col][0]
let type = ''
switch (typeof value) {
case 'number': {
@@ -39,7 +43,8 @@ export default {
default: type = 'TEXT'
}
result += `"${col}" ${type}, `
})
}
result = result.replace(/,\s$/, ');')
return result
},