Q:

MongoDB insertion not working

I am new to MongoDb, and I have a question about the insertion of data. My Mongoose schema for 'user' collection:
var user = new mongoose.Schema({

  username : {type: String},
  email    : {type: String,index: {unique: true}},
  password : {type: String},
  feed     : [{
                title       : {type: String},
                description : {type: String},
                latitude    : {type:Number},
                longitude   : {type:Number},
                feedImages  : [{imageUrl: {type: String}}]
             }]
});

Here I inserted data to username, email and password in my first service call:
app.post('/users',function(req,res) {

    var username = req.body.username;
    var email    = req.body.email;
    var password = req.body.password;

    var userData = {'username':username,'email':email,'password':password};
    new db.user(userData).save(function(err,result){
      if (err) {
         res.json({"success": '0', "message": "Error adding data"});
        }
      else {
             res.json({"success": '1', "message": "Data added"});
        }
     });
 });

Then I tried to insert data to feed for the above id.
app.post('/feeds',function(req,res) {
    var _id         = req.body._id;
    var title       = req.body.title;
    var description = req.body.description;
    var latitude    = req.body.latitude;
    var longitude   = req.body.longitude;
    db.user.update(
        {_id:_id },
          {$push : {
              feeds:[{
                title: title,
                description: description,
                latitude:latitude,
                longitude:longitude

              }]
          }
        }
    ,function (err,result) {
            console.log(err);
                if (err) {
                    res.json({"success": '0', "message": "Error adding data"});
                }
                else {
                    res.json({"success": '1', "message": "Data added"});
                }
        });

});

No error is shown, but the data insertion is not happening.

A:

Your latitude and longitude should be converted to numbers:

var latitude    = Number(req.body.latitude);
var longitude   = Number(req.body.longitude);

