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