async function create(req, res) {
  const { config, models, body, user, appLog, webhooks } = req;
  const {
    queryId,
    name,
    connectionId,
    connectionClientId,
    batchText,
    selectedText,
    chart,
  } = body;

  const batch = {
    queryId,
    name,
    connectionId,
    connectionClientId,
    batchText,
    selectedText,
    chart,
    userId: user.id,
  };

  const connection = await models.connections.findOneById(connectionId);
  const newBatch = await models.batches.create(batch);

  webhooks.batchCreated(user, connection, newBatch);
  for (const statement of newBatch.statements) {
    webhooks.statementCreated(user, connection, newBatch, statement);
  }

  // Run batch, but don't wait for it to send response
  // Client will get status via polling or perhaps some future event mechanism
  if (newBatch.status !== 'error') {
    if (connection.isAsynchronous) {
      // Wait for all execution IDs to be available for cancellation
      await executeCancellableBatch(
        config,
        models,
        webhooks,
        newBatch.id
      ).catch((error) => appLog.error(error));
    }
    executeBatch(config, models, webhooks, newBatch.id).catch((error) =>
      appLog.error(error)
    );
  }

  return res.utils.data(newBatch);
}
Create batch
@param {Req} req
@param {Res} res