mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 12:57:08 +00:00
Add pid2schema function.
Translates a project ID into a database schema name.
This commit is contained in:
@@ -49,6 +49,15 @@ async function schema2pid (schema, client) {
|
||||
return res.rows[0] && res.rows[0].pid;;
|
||||
}
|
||||
|
||||
async function pid2schema (pid, client) {
|
||||
if (!client) {
|
||||
client = await pool.connect();
|
||||
}
|
||||
const res = await client.query("SELECT schema FROM projects WHERE pid = $1", [pid]);
|
||||
client.release();
|
||||
return res.rows[0] && res.rows[0].schema;
|
||||
}
|
||||
|
||||
/** Fetch one row from a database cursor.
|
||||
*
|
||||
* @a cursor A query cursor
|
||||
@@ -75,5 +84,6 @@ module.exports = {
|
||||
transaction,
|
||||
setSurvey,
|
||||
schema2pid,
|
||||
pid2schema,
|
||||
fetchRow
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user