text: "use strict";
  
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.allArticle = allArticle;
  exports.articleDetails = articleDetails;
  exports.createArticle = createArticle;
  exports.deleteArticle = deleteArticle;
  exports.updateArticles = updateArticles;
  
  var _articles = _interopRequireDefault(require("../models/articles.js"));
  
  //Create Article
  function createArticle(req, res) {
    var article = new _articles["default"](req.body);
    article.save().then(function (result) {
      res.status(200).send({
        message: "Article creatred successfully",
        article: result
      });
    })["catch"](function (error) {
      res.json({
        error: error
      });
    });
  } //All Article
  
  
  function allArticle(req, res) {
    _articles["default"].find().then(function (result) {
      res.json({
        articles: result
      });
    })["catch"](function (error) {
      res.json({
        error: error
      });
    });
  } //Article Details
  
  
  function articleDetails(req, res) {
    var id = req.params.id;
  
    _articles["default"].findById(id).then(function (result) {
      res.json({
        article: result
      });
    })["catch"](function (err) {
      res.json({
        error: err
      });
    });
  } //Delete Article
  
  
  function deleteArticle(req, res) {
    var id = req.params.id;
  
    _articles["default"].findByIdAndDelete(id).then(function (result) {
      res.json({
        article: result
      });
    })["catch"](function (err) {
      console.log(err);
    });
  }
  
  function updateArticles(req, res) {
    var id = req.params.id;
    var updateArticle = {
      title: req.body.title,
      author: req.body.author,
      content: req.body.content
    };
  
    _articles["default"].findByIdAndUpdate(id, {
      $set: updateArticle
    }).then(function () {
      res.json({
        message: "article updated successfully"
      });
    })["catch"](function (err) {
      res.json({
        message: err
      });
    });
  }