mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9edeafd40 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sqliteviz",
|
||||
"version": "0.13.1",
|
||||
"version": "0.13.2",
|
||||
"license": "Apache-2.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -13,7 +13,14 @@ export default {
|
||||
result.columns = source.meta.fields.map(col => col.trim())
|
||||
result.values = source.data.map(row => {
|
||||
const resultRow = []
|
||||
source.meta.fields.forEach(col => { resultRow.push(row[col]) })
|
||||
source.meta.fields.forEach(col => {
|
||||
let value = row[col]
|
||||
if (value instanceof Date) {
|
||||
value = value.toISOString()
|
||||
}
|
||||
resultRow.push(value)
|
||||
})
|
||||
|
||||
return resultRow
|
||||
})
|
||||
} else {
|
||||
|
||||
@@ -11,18 +11,18 @@ describe('csv.js', () => {
|
||||
it('getResult with fields', () => {
|
||||
const source = {
|
||||
data: [
|
||||
{ id: 1, 'name ': 'foo' },
|
||||
{ id: 2, 'name ': 'bar' }
|
||||
{ id: 1, 'name ': 'foo', date: new Date('2021-06-30T14:10:24.717Z') },
|
||||
{ id: 2, 'name ': 'bar', date: new Date('2021-07-30T14:10:15.717Z') }
|
||||
],
|
||||
meta: {
|
||||
fields: ['id', 'name ']
|
||||
fields: ['id', 'name ', 'date']
|
||||
}
|
||||
}
|
||||
expect(csv.getResult(source)).to.eql({
|
||||
columns: ['id', 'name'],
|
||||
columns: ['id', 'name', 'date'],
|
||||
values: [
|
||||
[1, 'foo'],
|
||||
[2, 'bar']
|
||||
[1, 'foo', '2021-06-30T14:10:24.717Z'],
|
||||
[2, 'bar', '2021-07-30T14:10:15.717Z']
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user