{"size": 1213, "ext": "js", "max_stars_repo_path": "server/controllers/sueloController.js", "max_stars_repo_name": "Entx/Pachalov", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/controllers/sueloController.js", "max_issues_repo_name": "Entx/Pachalov", "max_issues_repo_issues_event_min_datetime": "2021-05-11T04:37:00.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-26T05:57:03.000Z", "max_forks_repo_path": "server/controllers/sueloController.js", "max_forks_repo_name": "SEDRICISAAC/Pachalov", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 5, "max_forks_count": null, "avg_line_length": 21.6607142857, "max_line_length": 61, "alphanum_fraction": 0.5704863974}
const express = require('express');
const mongoose = require('mongoose');
const routerApi = express.Router();
const db = mongoose.connect('mongodb://localhost/PachaLove');
const SueloModel = require('../db/models/sueloModel')

routerApi.route('/suelo/allSuelo')
  .get((req, res) => {
    SueloModel.find((err,resp) => {
      if(err){
        return res.json(err);
      }
      return res.json(resp)
    })
  });

routerApi.route('/suelo/newSuelo')
  .post((req, res) => {
    let suelos = new SueloModel(req.body)

    suelos.save((err,resp) => {
      if(err){
        return res.json(err);
      }
      console.log('listooooo')
      return res.json(resp)
    })
  });

routerApi.route('/suelo/updateSuelo')
  .put((req, res) => {
    let id = req.body.id
    let Query = req.body

    SueloModel.updateOne({'_id': id}, Query, (err,resp) => {
      if(err){
        return res.json(err);
      }
      return res.json(resp)
    })
  });

routerApi.route('/suelo/deleteSuelo')
  .delete((req, res) => {
    let id = req.body.id

    SueloModel.deleteOne({"_id": id}, (err,resp) => {
      if(err){
        return res.json(err);
      }
      return res.json(resp)
    })
  });

  module.exports = routerApi;
