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

async function get (projectId, opts = {}) {
	try {
		const client = await setSurvey(); // Use public schema

		const text = `
			SELECT meta
			FROM projects
			WHERE pid = $1;
		`;

		const res = await client.query(text, [projectId]);
		client.release();
		return res.rows[0].meta;
	} catch (err) {
		if (err.code == "42P01") {
			throw { status: 404, message: "Not found" };
		} else {
			throw err;
		}
	}
}

module.exports = get;
