CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/database/pool/account/get.ts
Views: 687
1
import getPool from "@cocalc/database/pool";
2
3
// raises an exception if no such account.
4
export default async function getAccountId({
5
email_address,
6
}: {
7
email_address: string;
8
}): Promise<string> {
9
const pool = getPool("medium");
10
const { rows } = await pool.query(
11
"SELECT account_id FROM accounts WHERE email_address=$1",
12
[email_address]
13
);
14
if (rows.length == 0) {
15
throw Error(`no account with email address '${email_address}'`);
16
}
17
const { account_id } = rows[0];
18
return account_id;
19
}
20
21