sort tables ok

This commit is contained in:
2021-06-15 19:36:51 -05:00
parent 6dbb3c80c5
commit 14f9937d93
11 changed files with 109 additions and 85 deletions

View File

@@ -5,8 +5,12 @@ const { checkAuth } = require("../middlewares/authentication");
router.get("/compras", checkAuth, async (req, res) => {
var compras;
compras = await Compra.find({ user: req.userData._id }).sort({
let miFiltro = req.get('filtro');
const filtros = {
fecha: { $regex: miFiltro, $options: "i" },
};
compras = await Compra.find({$and:[{ user: req.userData._id },filtros]}).sort({
fecha: "desc",
});

View File

@@ -5,7 +5,13 @@ const { checkAuth } = require("../middlewares/authentication");
router.get("/ingreso", checkAuth, async (req, res) => {
var Ingresos;
Ingresos = await Ingreso.find({ user: req.userData._id }).sort({
let miFiltro = req.get('filtro');
const filtros = {
fecha: { $regex: miFiltro, $options: "i" },
};
Ingresos = await Ingreso.find({$and:[{ user: req.userData._id },filtros]}).sort({
fecha: "desc",
});

View File

@@ -5,9 +5,11 @@ const { checkAuth } = require("../middlewares/authentication");
router.get("/presupuesto", checkAuth, async (req, res) => {
var presupuestos;
let limite = req.get('limite');
presupuestos = await presupuesto.find({ user: req.userData._id }).sort({
date: "desc",
});
}).limit(parseInt(limite));
return res.send({
status: "ok",