const { setSurvey, pool } = require('../connection');

async function get () {
	const text = `
		SELECT
			pid,
			name,
			schema,
			COALESCE(meta->'groups', '[]'::jsonb) AS groups,
			COALESCE(meta->'organisations', '{}'::jsonb) AS organisations,
			COALESCE(meta->'archived', 'false'::jsonb) AS archived
		FROM public.projects;
	`;
	const res = await pool.query(text);
	return res.rows;
}

module.exports = get;
