Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

503
Views
PSQL: error: relation does not exist

I am getting an Error when I do a get request with Express from my database and I am not sure what it means. Here is a short form of the error:

{ error: relation "movies" does not exist at Connection.parseE

Here is my code (server.js):

var express = require('express');
var bodyParser = require('body-parser');
var knex = require("./db/knex");
var movies = require('./routes/movies.js');
var actors = require('./routes/actors.js');
var roles = require('./routes/roles.js');
var app = express();
var port = process.env.PORT || 8000;

// body parser
app.use(bodyParser.json());

// router
// get all
app.get("/movies", movies.getAllMovies);

app.listen(port, function() {
  console.log("Now listening on port " + port);
});

Module (movies.js):

var knex = require("../db/knex");

// get all
var getAllMovies = function(req, res) {
  knex.raw('SELECT * FROM movies')
  .then(function(movies) {
    res.send(movies.rows);
  }).catch(function(err) {
    console.log(err);
  });
}

module.exports = {
   getAllMovies:getAllMovies,
   getOneMovie:getOneMovie,
   postMovie:postMovie,
   putMovie:putMovie,
   deleteMovie:deleteMovie
 }

Please let me know if you can find the error!

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I actually figured it out. All the variables and tables were fine, but one of my knex configuration files was not connected to the correct database.

Original:

module.exports = {
      development: {
          client: 'pg',
          connection: 'postgres://localhost/stores', // ** WRONG **
          migrations: {
              directory: __dirname + '/db/migrations',
            },
          seeds: {
              directory: __dirname + '/db/seeds',
            },
        },
 }

Line 4 should have read:

connection: 'postgres://localhost/movies_and_actors'
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!