I have a problem when I try to update an embedded document in mongodb. I tried two methods and did not work, and I searched everywhere for reasons why this is not being updated. In any case, my schema looks like this (I can notice that the embedded document I'm trying to update is a mixed type).
var UserModel = new mongoose.Schema({ account: String, salt: String, password: String, highlight_words: String, networks: {}, ip: String, ident: String, is_connected: Boolean, account_type: String });
I tried updating the "network" with these two pieces of code and did not work. I'm going to pull my hair out.
self.userModel.update({account: key}, {networks: self.client_data[key]['networks']}, function(err) {});
And (note that I tried adding a save () callback and it runs without errors)
self.userModel.findOne({account: key}, function(err, doc) { doc.networks = self.client_data[key]['networks']; doc.markModified('networks').save(); });
Any help would be appreciated! Thanks!
Edit:
The problem was that the object was like {'some.thing': {more: 'stuff'}}
, obviously he didn’t like it. which is understandable!
source share