title: Using socket io and canvas, store datas by id
body: <p>Im totally new to stack (and forums) so apologies if im missing thing :p</p>
  
  <p>So I'm using socket io to store the infos of my canvas drawings, and I want to store my datas like this</p>
  
  <pre><code> global{
      session
          cursor{
              x
              y
          }
          line{
              id 
              infos{
                  x
                  y
                  radius
                  color
                  type
              }
          }
  }
  </code></pre>
  
  <p>At the moment I have a "<code>onMouseDrag</code>" function </p>
  
  <pre><code>function onMouseDrag(event) {
      var id = myPath.id;
      var type = event.type;
      var x = event.middlePoint.x;
      var y = event.middlePoint.y;
      var color = "red";
      drawItem( x, y, color );
      EnvoieOnMouseDraging( x, y, color,type,id );
  }
  </code></pre>
  
  <p>which call this function :</p>
  
  <pre><code>function EnvoieOnMouseDraging( x, y, color,type,id) {
      var data = {
          id: id,
          infos: {
              x: x,
              y: y,
              color: color,
              type: type,
              id: id
          }
      };
  
      io.emit( 'drawCircle', data)
  }
  </code></pre>
  
  <p>So its working fine but if you watch the result which is logged I have something like this </p>
  
  <p><a href="https://i.stack.imgur.com/qKuyS.png" rel="nofollow noreferrer">infos stored in nodeserver</a></p>
  
  <p>As you can see it create multiple objects with same id. </p>
  
  <p>Now what I wanna do is to store all the datas with the same id in one object. In that case one path will be an object and i will be able to delete the last path.</p>
  
  <p>If you think I don't clear enough go to the good direction and if you have an easiest way to do that I'm up.</p>
  
  <p>Thanks guys,
  cheers</p>