Skip to content

Instantly share code, notes, and snippets.

@aleksejkozin
Created December 1, 2021 19:57
Show Gist options
  • Save aleksejkozin/f3f21e72b736b32319de4f71482d948c to your computer and use it in GitHub Desktop.
Save aleksejkozin/f3f21e72b736b32319de4f71482d948c to your computer and use it in GitHub Desktop.
const App = require("../model/app.model.js");
// Create and Save a new Message
exports.create = (req, res) => {
const message = new App({
message: req.body.message,
});
message
.save()
.then((data) => {
res.send(data);
})
.catch((err) => {
res.status(500).send({
message:
err.message || "Some error occurred while creating the Message.",
});
});
};
// Retrieve all messages from the database.
exports.findAll = (req, res) => {
App.find()
.then((data) => {
res.send(data);
})
.catch((err) => {
res.status(500).send({
message:
err.message || "Some error occurred while retrieving messages.",
});
});
};
// ... more CRUD routes like this ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment