File size: 528 Bytes
4b876a7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 'use strict';
const mongoose = require('mongoose');
const Weight = require('../models/weight');
module.exports = function (req, res) {
Weight.find({
user: req.user.sub.toString()
}, {'_id':0, 'date':1, 'user':1, 'weight':1, 'feel':1},
function (err, weights) {
if (err) {
res.send(err);
} else {
var nWeights = weights.sort(function(a,b){
return new Date(a.date) - new Date(b.date);
});
res.json(nWeights);
}
})
}
|