Created
May 10, 2020 11:51
-
-
Save debbysa/75fb7537392f9f788fd49f8f8ab44c69 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// controllers/movieController.js | |
const Movie = require("../models/Movie") | |
module.exports = { | |
index: function(req, res) { | |
Movie.findAll().then(function(rows) { | |
res.render("movie/index", { data: rows }) | |
}) | |
}, | |
store: function(req, res) { | |
Movie.create(req.body).then(function (rows) { | |
res.json(rows) | |
}) | |
}, | |
update: function(req, res) { | |
Movie.findByPrimary(req.params.id).then(function(row) { | |
row.update(req.body) | |
res.redirect("/movie") | |
}) | |
}, | |
destroy: function(req, res) { | |
Movie.findByPrimary(req.params.id).then(function(row) { | |
row.destroy() | |
res.redirect("/movie") | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment