First I am making entries in mongodb by:
var device = new Device(inputDetailsJson); //device model instance
device.save(function(err) {
if (err) {
res.send(err);
} else {
res.write('Successful');
res.end();
}
});
This is the device model:
// Dependencies
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// Schema Definition
var deviceSchema=new Schema ({
"deviceId":{ type : String , unique: true},
"version":{ type : String },
"manufacturer":{ type : String },
"modelname":{ type : String },
});
// Model
module.exports = mongoose.model('de', deviceSchema);
This is the inputDetailsJson:
{
"deviceId":"3236172417",
"version":"5.2.3",
"manufacturer":"abc",
"modelname":"example"
}
These details are getting entered correctly, but when I try to update something, it reflects no changes.
var device=new Device();
device.update({deviceId:"3236172417"},{modelname:"test"}
,function(err) {
if (err) {
return console.error(err);
}
else{
res.write('successful');
res.end();
It displays 'successful' even though no changes are made in the mongodb database.