I just started studying the MEAN stack and I am stuck with a very trivial problem. I have created a model using mongoose using the code below:
var mongoose = require('mongoose');
var axisData = mongoose.Schema({ xaxis:String, yaxis:String });
module.exports = mongoose.model('AxisData',axisData);
And i am trying to save the above model using the below code:
var axisDataModel = require('../models/models');
where the "../models/models" is the location where the above defined model is stored.
module.exports.saveAxisData=function(req,res){
var axisData=new axisDataModel(req.body);
axisData.save(function(err){
if(err)
console.log(err);
else
console.log(todo);
});
};
But unfortunately, the callback inside save() never gets called. Whichever site I referred to, told the same thing. Can anyone help me?