INNER CODE UNIT · TypeScript
createUsersTable
vishalsingh2972/100xDevs_2.0 · 0-1 cohort/Week 10/10.1/src/index.ts:12
async function createUsersTable() {
await client.connect();
const result = await client.query(`
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
`);
console.log(result);
// await client.end(); // Close the connection after everything is done (adding 'await' just for safety so that code below/after this line never gets executed)
}
createUsersTable();