1
我收到一個錯誤,當我從我的數據庫使用Express獲取請求時,我不確定它的含義。下面是錯誤的簡短形式:PSQL:錯誤:關係不存在
{錯誤:關係 「電影」 在Connection.parseE
這裏不存在 是我的代碼(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);
});
模塊(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
}
請讓我知道如果你能找到錯誤!
你沒有一個叫做'movies'在你的數據庫似乎表? – Rishav