1var query = {'username': req.user.username};
2req.newData.username = req.user.username;
3
4MyModel.findOneAndUpdate(query, req.newData, {upsert: true}, function(err, doc) {
5 if (err) return res.send(500, {error: err});
6 return res.send('Succesfully saved.');
7});
8