jakubrohleder / angular-jsonapi

Simple and lightweight, yet powerful ORM for your frontend that seamlessly integrates with your JsonAPI server.
http://jakubrohleder.github.io/angular-jsonapi/
GNU General Public License v3.0
96 stars 34 forks source link

Remote add/update object with relationships in only one transaction #38

Open pablorsk opened 8 years ago

pablorsk commented 8 years ago

Hi!

We need add/update relational objects but in just only one transaction.

For example,

    var schema = {
      type: 'cars',
      id: 'string',
      attributes: {
        name: {presence: true}
      },
      relationships: {
        wheels: {
          included: true,
          type: 'hasMany'
        }
      }
   }

We need save car and the wheels, but if the wheels fail, car object should not be saved. The server evaluate object as a whole, not as simple parts.

In other words, we need just only one HTTP request for the car and wheels.

Of course, the example is for didactic purposes only.

Regards...