Estoy tratando de ejecutar el comando
const { Client } = require('pg'); const client = new Client({ host: 'localhost', port: 5432, user: 'root2', password: 'root2', database: 'mycontacts', }); client.connect(); client.query('SELECT * FROM contacts').then(console.log);pero luego obtuve el siguiente error:
relation "contacts" does not existMi código Postgres:
CREATE DATABASE mycontacts; CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE TABLE IF NOT EXISTS categories ( id UUID NOT NULL UNIQUE DEFAULT uuid_generate_v4(), name VARCHAR NOT NULL ); CREATE TABLE IF NOT EXISTS contacts ( id UUID NOT NULL UNIQUE DEFAULT uuid_generate_v4(), name VARCHAR NOT NULL, email VARCHAR UNIQUE, phone VARCHAR, category_id UUID, FOREIGN KEY(category_id) REFERENCES categories(id) );y
List of relations Schema | Name | Type | Owner --------+------------+-------+------- public | categories | table | root2 public | contacts | table | root2 (2 rows)Ya intenté poner el esquema antes (public.contacts) y comillas dobles, pero nada funcionó. ¿Algun consejo?