· 4 years ago · Aug 25, 2021, 06:22 AM
1const { Pool } = require('pg');
2
3const DATABASE_CONFIG = {
4 user: "postgres",
5 host: "db",
6 database: "database",
7 password: "postgres",
8 port: 5432,
9};
10
11module.exports.createCharacterTable = async () => {
12 const pool = new Pool(DATABASE_CONFIG)
13
14 const queryCharacter = `
15 CREATE TABLE IF NOT EXISTS characters
16 (
17 id SERIAL PRIMARY KEY NOT NULL,
18 name text NOT NULL,
19 data jsonb NOT NULL
20 );
21 `
22
23 pool.query(queryCharacter, (res, err) => {
24 console.log(res, err)
25 })
26
27 return null;
28}
29