mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 22:03:58 +00:00
xml quick export
This commit is contained in:
@@ -21,16 +21,17 @@ function escapeXml(value) {
|
|||||||
class StringifyStream extends stream.Transform {
|
class StringifyStream extends stream.Transform {
|
||||||
constructor({ itemElementName, rootElementName }) {
|
constructor({ itemElementName, rootElementName }) {
|
||||||
super({ objectMode: true });
|
super({ objectMode: true });
|
||||||
this.itemElementName = itemElementName;
|
this.itemElementName = itemElementName || 'row';
|
||||||
this.rootElementName = rootElementName;
|
this.rootElementName = rootElementName || 'root';
|
||||||
|
|
||||||
this.startElement(this.rootElementName);
|
this.startElement(this.rootElementName);
|
||||||
|
this.push('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
startElement(element) {
|
startElement(element) {
|
||||||
this.push('<');
|
this.push('<');
|
||||||
this.push(element);
|
this.push(element);
|
||||||
this.push('>\n');
|
this.push('>');
|
||||||
}
|
}
|
||||||
|
|
||||||
endElement(element) {
|
endElement(element) {
|
||||||
@@ -47,6 +48,7 @@ class StringifyStream extends stream.Transform {
|
|||||||
|
|
||||||
_transform(chunk, encoding, done) {
|
_transform(chunk, encoding, done) {
|
||||||
this.startElement(this.itemElementName);
|
this.startElement(this.itemElementName);
|
||||||
|
this.push('\n');
|
||||||
for (const key of Object.keys(chunk)) {
|
for (const key of Object.keys(chunk)) {
|
||||||
this.elementValue(key, chunk[key]);
|
this.elementValue(key, chunk[key]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,5 +30,19 @@ const fileFormat = {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
fileFormats: [fileFormat],
|
fileFormats: [fileFormat],
|
||||||
|
|
||||||
|
quickExports: [
|
||||||
|
{
|
||||||
|
label: 'XML file',
|
||||||
|
extension: 'xml',
|
||||||
|
createWriter: (fileName) => ({
|
||||||
|
functionName: 'writer@dbgate-plugin-xml',
|
||||||
|
props: {
|
||||||
|
fileName,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Reference in New Issue
Block a user