mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 12:17:08 +00:00
Add DB function to return project configuration.
NOTE: mostly redundant with db.configuration.get(), see previous commit.
This commit is contained in:
25
lib/www/server/lib/db/project/configuration/get.js
Normal file
25
lib/www/server/lib/db/project/configuration/get.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
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];
|
||||||
|
} catch (err) {
|
||||||
|
if (err.code == "42P01") {
|
||||||
|
throw { status: 404, message: "Not found" };
|
||||||
|
} else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = get;
|
||||||
8
lib/www/server/lib/db/project/configuration/index.js
Normal file
8
lib/www/server/lib/db/project/configuration/index.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
module.exports = {
|
||||||
|
get: require('./get'),
|
||||||
|
// post: require('./post'),
|
||||||
|
// put: require('./put'),
|
||||||
|
// patch: require('./patch'),
|
||||||
|
// delete: require('./delete'),
|
||||||
|
};
|
||||||
@@ -5,4 +5,5 @@ module.exports = {
|
|||||||
put: require('./put'),
|
put: require('./put'),
|
||||||
delete: require('./delete'),
|
delete: require('./delete'),
|
||||||
summary: require('./summary'),
|
summary: require('./summary'),
|
||||||
|
configuration: require('./configuration'),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user