I am trying to retrieve time data from MongoDB using AngularJS.
The tricky part is that I am using MongoJS without having a schema for my time data thus I cannot query it directly. Whenever I pull data from my database, I receive it in a format of:
2017-06-29T23:00:00.000Z
my main issue is that I don't use schema to set up a specific format of the data and I want it to display in:
dd/mm/yyyy
This is my NodeJS code used for the overall data input, get, delete and edit:
app.post('/posts', function(req,res){
dbc.posts.insert(req.body, function(err, doc){
res.json(doc);
})
});
app.delete('/posts/:id', function(req,res){
var id = req.params.id;
console.log(id);
dbc.posts.remove({_id: mongojs.ObjectId(id)}, function(err, doc){
res.json(doc);
})
});
app.get('/posts/:id', function(req,res){
var id = req.params.id;
console.log(id);
dbc.posts.findOne({_id: mongojs.ObjectId(id)}, function(err, doc){
res.json(doc);
});
});
app.put('/posts/:id', function(req, res){
var id = req.params.id;
console.log(req.body.system);
dbc.posts.findAndModify({query:{_id:mongojs.ObjectId(id)},
update: {$set: {issue: req.body.issue, system: req.body.system, date: req.body.date, priority: req.body.priority, description: req.body.description, status: req.body.status}},
new:true}, function(err, doc){
res.json(doc);
console.log(req.body.date);
});
});
How can I filter my data in my AngularJS controller to display it in the format I want, since I don't use a specific schema for the database?