Change db.configuration.get() to use database.

NOTE: this endpoint is redundant with db.project.configuration.get()
except for its ability to return a partial tree.

TODO: merge this with db.project.configuration.get().
This commit is contained in:
D. Berge
2023-08-21 14:46:51 +02:00
parent 63b9cc5b16
commit 60ed850d2d

View File

@@ -1,17 +1,9 @@
const { setSurvey } = require('../connection');
const { setSurvey, pool } = require('../connection');
async function get (projectId, path, opts = {}) {
const client = await setSurvey(projectId);
const text = `
SELECT data
FROM file_data fd
INNER JOIN files f USING (hash)
WHERE f.path LIKE '%.yaml';
`;
const res = await client.query(text);
client.release();
const text = `SELECT meta FROM public.projects WHERE pid = $1;`;
const res = await pool.query(text, [projectId]);
const config = res.rows.length == 1
? res.rows[0].data