Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let db = mongoose.connection,
- 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',
- port = 4000;
- const mongoose = require('mongoose');
- let shema_tareas = new mongoose.Schema(
- {
- nombre: { type: String, required: true },
- fecha: { type: Date, required: true },
- prioridad: { type: String, required: true },
- encargado: { type: String, required: true },
- decripcion: { type: String, required: true },
- estado: { type: String, require: true }
- }
- );
- module.exports= mongoose.model('tarea', shema_tareas);
- const modelo_tareas = require('./tareas.model')
- module.exports.registrar = (req, res) => {
- let nuevo_tarea = new modelo_tareas(
- {
- nombre: req.body.nombre,
- fecha: req.body.fecha,
- prioridad: req.body.prioridad,
- encargado: req.body.encargado,
- descripcion: req.body.de,
- estado: 'Activo'
- }
- );
- nuevo_tarea.save(function (error) {
- if (error) {
- res.json(
- {
- success: false,
- msg: `No se pudo registrar el tarea, ocurrió el siguiente error ${error}`
- }
- );
- } else {
- res.json(
- {
- success: true,
- msg: `Se registro correctamente el tarea.`
- }
- )
- }
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement