# How to implement REST transaction handling with ember data?

**URL:** <https://discuss.emberjs.com/t/how-to-implement-rest-transaction-handling-with-ember-data/7194>\
**Category:** Ember Data\
**Created:** [January 30, 2015, 2:46pm UTC](https://discuss.emberjs.com/t/how-to-implement-rest-transaction-handling-with-ember-data/7194 "2015-01-30T14:46:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dennismende](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dennismende/32/9958_2.png) [@dennismende](https://discuss.emberjs.com/u/dennismende)\
**Post date:** [January 30, 2015, 2:46pm UTC](https://discuss.emberjs.com/t/how-to-implement-rest-transaction-handling-with-ember-data/7194/1 "2015-01-30T14:46:59Z")

</div>

I tried to figure out how to implement transactions. All resources I found aren’t really good. Has someone any good resources of how to realise REST transactions?

If someone implemented transactions combined with ember data then please let us talk.

---

<div class="post-metadata">

**Author:** ![jcope2013](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jcope2013/32/9878_2.png) [@jcope2013](https://discuss.emberjs.com/u/jcope2013)\
**Post date:** [January 30, 2015, 3:13pm UTC](https://discuss.emberjs.com/t/how-to-implement-rest-transaction-handling-with-ember-data/7194/2 "2015-01-30T15:13:23Z")

</div>

```
invoice.save().then(function(invoice){
            self.set('content.invoiceId', parseInt(invoice.id, 10));
            invoice.get('lineItems').then(function(lineItems){
                self.get('content').save().then(self.didSave.bind(self), self.paymentDidNotSave.bind(self));
            });
        }, function(error) {      
            lineItem.deleteRecord();
            invoice.deleteRecord();
        });

```

wrap the deleteRecord’s in the error handling callbacks of promises and if anything fails make to sure delete everything else
