I am developing a sails.js application
application model
name: String,
address:String,
appSettings: {
header: String,
color : String,
font: String,
}
I am using an independent update request update color and update font in appSetting
I added an update request here
for string color inside appSettings
var data = {
appSettings:{
color : 'red'
}
};
var query = {_id:'xxxxxxxxxx'};
Application.update(query,data).exec(function(err,application) {
if (err) res.send(err);
res.send({message:'Success'});
});
for the font string inside appSettings
var data = {
appSettings:{
font : 'Times-New-Roman'
}
};
var query = {_id:'xxxxxxxxxx'};
Application.update(query,data).exec(function(err,application) {
if (err) res.send(err);
res.send({message:'Success'});
});
Result JSON file ,
{
"name" : "Water Colors",
"address" : "No 25, Kandy Road, Colombo",
"appSettings": {
"font" : "Times-New-Roman"
}
}
The problem is that when you run one request, the appSettings updates are overwritten
How to update font line inside appSettings line without overwriting color line in appSettings?
Hope answer if not clear pls comments