'relation does not exist - Postgres/docker

I'm trying to run the command

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);

but then i got the following error:

relation "contacts" does not exist

My Postgres code:

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)
);

and

List of relations
 Schema |    Name    | Type  | Owner
--------+------------+-------+-------
 public | categories | table | root2
 public | contacts   | table | root2
(2 rows)

I already tried to put the schema before (public.contacts) and double quotes around it but nothing worked. Any tips?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source