Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exports.create = (req, res) => {
- // Save to MySQL database
- Student.create({
- Name:req.body.Name
- }).then(student => {
- // Send created customer to client
- res.send(student);
- });
- };
- // FETCH all Customers
- exports.findAll = (req, res) => {
- Student.findAll().then(students => {
- // Send all customers to Client
- res.send(students);
- });
- };
- // Find a Customer by Id
- exports.findById = (req, res) => {
- Student.findOne({where: {id: req.params.studentId}})
- .then(student => {
- res.send(student);
- })
- };
- // Update a Customer
- exports.update = (req, res) => {
- const id = req.params.studentId;
- Student.update( { Name:req.body.Name},
- { where: {id: req.params.studentId} }
- ).then(() => {
- res.status(200).send("updated
- successfully with id = " + id);
- });
- };
- // Delete a Customer by Id
- exports.delete = (req, res) => {
- const id = req.params.studentId;
- Student.destroy({
- where: { id: id }
- }).then(() => {
- res.status(200).send('deleted successfully with id = ' + id);
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement