Add setSurvey() utility function to DB interface.

It sets the current survey and optionally returns a
client connection to use in subsequent queries.
This commit is contained in:
D. Berge
2020-08-16 10:16:08 +02:00
parent dc1e08b452
commit ecbe4d38ca

View File

@@ -28,7 +28,16 @@ const transaction = {
}
};
async function setSurvey (projectId, client) {
if (!client) {
client = await pool.connect();
}
await client.query("CALL set_survey($1);", [projectId]);
return client;
}
module.exports = {
pool,
transaction,
setSurvey
};