How to use the conseiljs.ConseilQueryBuilder.setOutputType function in conseiljs

To help you get started, we’ve selected a few conseiljs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Cryptonomic / Arronax / src / reducers / app / thunks.ts View on Github external
export const exportCsvData = () => async (dispatch, state) => {
  const { selectedEntity, columns, sort, selectedFilters, selectedConfig, aggregations } = state().app;
  const { platform, network, url, apiKey } = selectedConfig;
  const serverInfo = { url, apiKey, network };

  const attributeNames = getAttributeNames(columns[selectedEntity]);
  let query = getMainQuery(attributeNames, selectedFilters[selectedEntity], sort[selectedEntity], aggregations[selectedEntity]);
  query = ConseilQueryBuilder.setOutputType(query, ConseilOutput.csv);
  query = ConseilQueryBuilder.setLimit(query, 50000);

  const result: any = await executeEntityQuery(serverInfo, platform, network, selectedEntity, query);
  let blob = new Blob([result]);
  if (window.navigator.msSaveOrOpenBlob) {
    window.navigator.msSaveBlob(blob, 'arronax-results.csv');
  } else {
    const a = window.document.createElement("a");
    a.href = window.URL.createObjectURL(blob);
    a.download = 'arronax-results.csv';
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
  }
}