create_db_view = async (context, req) => {
  const table = Table.findOne({ id: context.table_id });
  const fields = table.getFields();
  const { joinFields, aggregations } = picked_fields_to_query(
    context.columns,
    fields,
    undefined,
    req,
    table
  );

  const { sql } = await table.getJoinedQuery({
    where: {},
    joinFields,
    aggregations,
  });
  const schema = db.getTenantSchemaPrefix();
  // is there already a table with this name ? if yes add _sqlview
  const extable = Table.findOne({ name: context.viewname });
  const sql_view_name = `${schema}"${db.sqlsanitize(context.viewname)}${
    extable ? "_sqlview" : ""
  }"`;
  await db.query(`drop view if exists ${sql_view_name};`);
  await db.query(`create or replace view ${sql_view_name} as ${sql};`);
}
@param {object} context
@returns {Promise<void>}