SELECT 
	d.id                     AS id,
	d.officialname           AS name,
	array_agg(DISTINCT a.id) AS apis
FROM
	datasources d
	LEFT OUTER JOIN api a ON (d.id = a.datasource)
WHERE
	datasourceclass = '$type$'
GROUP BY 
	d.id,
	d.officialname
ORDER BY
	d.officialname
	