2020-12-30 13:58:39 +01:00
|
|
|
import API from "./api"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetches all rows from a query.
|
|
|
|
*/
|
2021-01-06 13:28:51 +01:00
|
|
|
export const fetchQueryData = async ({ _id }) => {
|
2020-12-30 13:58:39 +01:00
|
|
|
const response = await API.get({
|
2021-01-06 13:28:51 +01:00
|
|
|
url: `/api/queries/${_id}`,
|
2020-12-30 13:58:39 +01:00
|
|
|
})
|
|
|
|
return response.rows
|
|
|
|
}
|
2021-01-04 19:57:16 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Executes a query against an external data connector.
|
|
|
|
*/
|
2021-01-08 13:06:37 +01:00
|
|
|
export const executeQuery = async ({ queryId, params }) => {
|
2021-01-04 19:57:16 +01:00
|
|
|
const response = await API.post({
|
2021-01-08 13:06:37 +01:00
|
|
|
url: `/api/queries/${queryId}`,
|
|
|
|
body: {
|
|
|
|
params,
|
|
|
|
},
|
2021-01-04 19:57:16 +01:00
|
|
|
})
|
|
|
|
return response.rows
|
|
|
|
}
|