mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 08:37:07 +00:00
21 lines
536 B
JavaScript
21 lines
536 B
JavaScript
const { setSurvey, pool } = require('../connection');
|
|
|
|
async function get (projectId, path, opts = {}) {
|
|
|
|
const text = `SELECT meta data FROM public.projects WHERE pid = $1;`;
|
|
const res = await pool.query(text, [projectId]);
|
|
|
|
const config = res.rows.length == 1
|
|
? res.rows[0].data
|
|
: res.rows.map(r => r.data);
|
|
|
|
if (path) {
|
|
return path.split('/').filter(i => i !== "").reduce( (obj, idx) =>
|
|
(typeof obj !== 'undefined' && obj !== null) ? obj[idx] : undefined, config);
|
|
} else {
|
|
return config;
|
|
}
|
|
}
|
|
|
|
module.exports = get;
|