Skip to content Skip to sidebar Skip to footer

Node.js Update Element In Mongodb

I have the following Mongoose schema and model: var deviceSchema = new Schema({ deviceId:String, deviceName:String, devicePlace:String, socket : [{number: Number,n

Solution 1:

Add the callback to the update statement to see the error trace.

     device.update({deviceId:newData.deviceId,'socket.number':newData.number}
                  ,{$set: {"socket.$.name" : newData.name}}
                  ,function(error,updatedDevice){

         if(error) throw error;
         // or : console.log("update error",error.message);
    })

Post a Comment for "Node.js Update Element In Mongodb"