Merge pull request #6354 from Budibase/bug/sev2/export-rows-external-table
Bug fix for exporting selected rows from External Datasource
This commit is contained in:
commit
b8f0be6df6
|
@ -155,27 +155,22 @@ exports.validate = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.exportRows = async ctx => {
|
exports.exportRows = async ctx => {
|
||||||
const { datasourceId, tableName } = breakExternalTableId(ctx.params.tableId)
|
const { datasourceId } = breakExternalTableId(ctx.params.tableId)
|
||||||
const db = getAppDB()
|
const db = getAppDB()
|
||||||
let format = ctx.query.format
|
let format = ctx.query.format
|
||||||
const datasource = await db.get(datasourceId)
|
const datasource = await db.get(datasourceId)
|
||||||
if (!datasource || !datasource.entities) {
|
if (!datasource || !datasource.entities) {
|
||||||
ctx.throw(400, "Datasource has not been configured for plus API.")
|
ctx.throw(400, "Datasource has not been configured for plus API.")
|
||||||
}
|
}
|
||||||
const tables = datasource.entities
|
|
||||||
const table = tables[tableName]
|
|
||||||
ctx.request.body = {
|
ctx.request.body = {
|
||||||
query: {
|
query: {
|
||||||
oneOf: {
|
oneOf: {
|
||||||
[table.primaryDisplay]: ctx.request.body.rows.map(
|
_id: ctx.request.body.rows.map(row => JSON.parse(decodeURI(row))[0]),
|
||||||
id => breakRowIdField(id)[0]
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = await exports.search(ctx)
|
let result = await exports.search(ctx)
|
||||||
|
|
||||||
let headers = Object.keys(result.rows[0])
|
let headers = Object.keys(result.rows[0])
|
||||||
const exporter = exporters[format]
|
const exporter = exporters[format]
|
||||||
const filename = `export.${format}`
|
const filename = `export.${format}`
|
||||||
|
|
Loading…
Reference in New Issue