mirror of
https://github.com/dbgate/dbgate
synced 2024-11-12 22:55:31 +00:00
refactor
This commit is contained in:
parent
56f015ffd5
commit
f080b18d3f
@ -6,7 +6,7 @@ const copyStream = require('./copyStream');
|
|||||||
const fakeObjectReader = require('./fakeObjectReader');
|
const fakeObjectReader = require('./fakeObjectReader');
|
||||||
const consoleObjectWriter = require('./consoleObjectWriter');
|
const consoleObjectWriter = require('./consoleObjectWriter');
|
||||||
const jsonLinesWriter = require('./jsonLinesWriter');
|
const jsonLinesWriter = require('./jsonLinesWriter');
|
||||||
const jsonArrayWriter = require('./jsonArrayWriter');
|
const jsonWriter = require('./jsonWriter');
|
||||||
const jsonLinesReader = require('./jsonLinesReader');
|
const jsonLinesReader = require('./jsonLinesReader');
|
||||||
const sqlDataWriter = require('./sqlDataWriter');
|
const sqlDataWriter = require('./sqlDataWriter');
|
||||||
const jslDataReader = require('./jslDataReader');
|
const jslDataReader = require('./jslDataReader');
|
||||||
@ -38,8 +38,9 @@ const dbgateApi = {
|
|||||||
tableReader,
|
tableReader,
|
||||||
copyStream,
|
copyStream,
|
||||||
jsonLinesWriter,
|
jsonLinesWriter,
|
||||||
jsonArrayWriter,
|
|
||||||
jsonLinesReader,
|
jsonLinesReader,
|
||||||
|
jsonReader,
|
||||||
|
jsonWriter,
|
||||||
sqlDataWriter,
|
sqlDataWriter,
|
||||||
fakeObjectReader,
|
fakeObjectReader,
|
||||||
consoleObjectWriter,
|
consoleObjectWriter,
|
||||||
@ -62,7 +63,6 @@ const dbgateApi = {
|
|||||||
dataDuplicator,
|
dataDuplicator,
|
||||||
dbModelToJson,
|
dbModelToJson,
|
||||||
jsonToDbModel,
|
jsonToDbModel,
|
||||||
jsonReader,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
requirePlugin.initializeDbgateApi(dbgateApi);
|
requirePlugin.initializeDbgateApi(dbgateApi);
|
||||||
|
@ -40,7 +40,7 @@ class StringifyStream extends stream.Transform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function jsonArrayWriter({ fileName, encoding = 'utf-8' }) {
|
async function jsonWriter({ fileName, encoding = 'utf-8' }) {
|
||||||
logger.info(`Writing file ${fileName}`);
|
logger.info(`Writing file ${fileName}`);
|
||||||
const stringify = new StringifyStream();
|
const stringify = new StringifyStream();
|
||||||
const fileStream = fs.createWriteStream(fileName, encoding);
|
const fileStream = fs.createWriteStream(fileName, encoding);
|
||||||
@ -49,4 +49,4 @@ async function jsonArrayWriter({ fileName, encoding = 'utf-8' }) {
|
|||||||
return stringify;
|
return stringify;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = jsonArrayWriter;
|
module.exports = jsonWriter;
|
@ -14,7 +14,32 @@ const jsonFormat = {
|
|||||||
extension: 'json',
|
extension: 'json',
|
||||||
name: 'JSON',
|
name: 'JSON',
|
||||||
readerFunc: 'jsonReader',
|
readerFunc: 'jsonReader',
|
||||||
writerFunc: 'jsonArrayWriter',
|
writerFunc: 'jsonWriter',
|
||||||
|
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
type: 'select',
|
||||||
|
name: 'jsonStyle',
|
||||||
|
label: 'JSON style',
|
||||||
|
options: [
|
||||||
|
{ name: 'Array', value: 'array' },
|
||||||
|
{ name: 'Object', value: 'object' },
|
||||||
|
],
|
||||||
|
apiName: 'jsonStyle',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'textbox',
|
||||||
|
name: 'keyField',
|
||||||
|
label: 'Key field',
|
||||||
|
apiName: 'keyField',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'textbox',
|
||||||
|
name: 'rootField',
|
||||||
|
label: 'Root field',
|
||||||
|
apiName: 'rootField',
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const sqlFormat = {
|
const sqlFormat = {
|
||||||
@ -39,7 +64,7 @@ const jsonQuickExport = {
|
|||||||
label: 'JSON',
|
label: 'JSON',
|
||||||
extension: 'json',
|
extension: 'json',
|
||||||
createWriter: fileName => ({
|
createWriter: fileName => ({
|
||||||
functionName: 'jsonArrayWriter',
|
functionName: 'jsonWriter',
|
||||||
props: {
|
props: {
|
||||||
fileName,
|
fileName,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user