title: Node.js update element in MongoDB
body: <p>I have the following Mongoose schema and model:</p>
  
  <pre><code>var deviceSchema = new Schema({
      deviceId:String,
      deviceName:String,
      devicePlace:String,
  
      socket : [{number: Number,name:String, state : Boolean, current: Number, image:Number,locked:Boolean,reserved:Boolean}]
  });
  </code></pre>
  
  <p>I already have a device in my database with four sockets.</p>
  
  <p>Here example!</p>
  
  <p>This is original data.</p>
  
  <pre><code>{
      "_id" : ObjectId("5626569006bc3da468bafe93"),
      "deviceId" : "0013A20040B5769A",
      "deviceName" : "device",
      "devicePlace" : "place",
      "__v" : 0,
      "socket" : [ 
          {
              "_id" : ObjectId("5628bd83570be84e28879e2d"),
              "number" : 0,
              "name" : "name"
              "state" : true,
              "current" : 0
              "image" : 0,
              "locked" : false,
              "reserved" : false,
          }, ...
      ]
  }
  </code></pre>
  
  <p>and I received data from client for update.</p>
  
  <pre><code>{
      "_id" : ObjectId("5626569006bc3da468bafe93"),
      "deviceId" : "0013A20040B5769A",
      "__v" : 0,
      "socket" : [ 
          {
              "_id" : ObjectId("5628bd83570be84e28879e2d"),
              "number" : 0,
              "name" : "new name!!!!!"
              "state" : true,
              "current" : 0
          }, ... 
      ]
  }
  </code></pre>
  
  <p>Now I'm trying to update a specific socket's name in the database with the following command:</p>
  
  <pre><code>device.update({deviceId: newData.deviceId, "socket.number": newData.number}, {$set: {"socket.$.name": newData.name}})
  </code></pre>
  
  <p>newData is object that extracted from socket array in received data.</p>
  
  <p>I want to just update first socket's name.
  or if possible, I want to update every socket's name as received socket array.</p>
  
  <p>But this does not seem to be working, but I get no error. Can someone pin point what I'm doing wrong?</p>