Files
dougal-software/lib/www/server/lib/db/project/summary/refresh.js
2023-11-02 13:25:34 +01:00

24 lines
459 B
JavaScript

const { setSurvey } = require('../../connection');
async function refresh (projectId, opts = {}) {
try {
const client = await setSurvey(projectId);
const text = `
REFRESH MATERIALIZED VIEW project_summary;
`;
const res = await client.query(text);
client.release();
return res.rows[0];
} catch (err) {
if (err.code == "42P01") {
throw { status: 404, message: "Not found" };
} else {
throw err;
}
}
}
module.exports = refresh;