title: AngularJS object serialisation shortcoming
body: <p>I am doing an angularJS application served by a node.js/mongodb backend.</p>
  
  <p>My server supply a rest API that store and return JSON object. Some of my mongodb schema have several ref that are populated on the fly before being served to the angularJS application. Some of my object are "complex", i.e. I've got an object which contains an array of objects, these objects have got a reference to my user. It seems that when I am using a $resource to update (PUT) this object on the server, the last level of indirection is not processed.</p>
  
  <p>instead of :</p>
  
  <pre><code>{
      enrollments: [
         {
             price: 100,
             userProfile: {
                 _id: 'xxxxxxxxxxxxxxxxxxxxxxx'
                 name: "Roger"
             }
         }
      ]
  }
  </code></pre>
  
  <p>I've got something like that :</p>
  
  <pre><code>{
      enrollments: [
         {
             price: 100,
             userProfile: [Object]
         }
      ]
  }
  </code></pre>
  
  <p>And so my update erase the information about the user profile in my database. Seems that after the third level the serializer stops looking for more data.</p>
  
  <p>I've done some extensive research in the AngularJS documentation, on stackoverflow but to no avail. Certainly because of the generic nature of this problem.</p>
  
  <p>My current conclusion would be to write a custom "request transformation" to change the way the JSON is serialized. But it is needed ? Is there a simpler way to solve this problem ?</p>
  
  <p>Thanks,
  Stéphane</p>