Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. let db = mongoose.connection,
  2. dburl = 'mongodb://xxxx:xxxx@proyecto-shard-00-00-qyxqa.mongodb.net:27017,proyecto-shard-00-01-qyxqa.mongodb.net:27017,proyecto-shard-00-02-qyxqa.mongodb.net:27017/tareas?ssl=true&replicaSet=proyecto-shard-0&authSource=admin&retryWrites=true',
  3.  
  4. port = 4000;
  5.  
  6. const mongoose = require('mongoose');
  7.  
  8. let shema_tareas = new mongoose.Schema(
  9. {
  10. nombre: { type: String, required: true },
  11. fecha: { type: Date, required: true },
  12. prioridad: { type: String, required: true },
  13. encargado: { type: String, required: true },
  14. decripcion: { type: String, required: true },
  15. estado: { type: String, require: true }
  16.  
  17. }
  18. );
  19. module.exports= mongoose.model('tarea', shema_tareas);
  20.  
  21. const modelo_tareas = require('./tareas.model')
  22.  
  23. module.exports.registrar = (req, res) => {
  24. let nuevo_tarea = new modelo_tareas(
  25. {
  26. nombre: req.body.nombre,
  27. fecha: req.body.fecha,
  28. prioridad: req.body.prioridad,
  29. encargado: req.body.encargado,
  30. descripcion: req.body.de,
  31. estado: 'Activo'
  32. }
  33. );
  34. nuevo_tarea.save(function (error) {
  35.  
  36. if (error) {
  37. res.json(
  38. {
  39. success: false,
  40. msg: `No se pudo registrar el tarea, ocurrió el siguiente error ${error}`
  41. }
  42. );
  43. } else {
  44.  
  45.  
  46. res.json(
  47. {
  48.  
  49. success: true,
  50. msg: `Se registro correctamente el tarea.`
  51.  
  52. }
  53. )
  54. }
  55.  
  56. });
  57.  
  58. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement