text: const sqlString = require('sqlstring-sqlite');
  
  const { getDb } = require('../db');
  
  const {
    formatOrderByClause,
    formatSelectClause,
    formatWhereClauses
  } = require('../utils');
  const attributionyModel = require('../../models/gtfs/attributions');
  
  /*
   * Returns an array of all attributions that match the query parameters.
   */
  exports.getAttributions = async (query = {}, fields = [], orderBy = []) => {
    const db = await getDb();
    const tableName = sqlString.escapeId(attributionyModel.filenameBase);
    const selectClause = formatSelectClause(fields);
    const whereClause = formatWhereClauses(query);
    const orderByClause = formatOrderByClause(orderBy);
  
    return db.all(`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`);
  };
  