# Transactions in Dgraph

**URL:** <https://discuss.dgraph.io/t/transactions-in-dgraph/1641>\
**Category:** Users\
**Created:** [July 26, 2017, 7:31am UTC](https://discuss.dgraph.io/t/transactions-in-dgraph/1641 "2017-07-26T07:31:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![calummoore](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/calummoore/32/614_2.png) [@calummoore](https://discuss.dgraph.io/u/calummoore)\
**Post date:** [July 26, 2017, 7:31am UTC](https://discuss.dgraph.io/t/transactions-in-dgraph/1641/1 "2017-07-26T07:31:17Z")

</div>

Is there any support for adding transactions to Dgraph?

I see the use cases as:

- financial transactions
- adding unique indexes (useful for user auth providers)
- allocating stock to an order / decrementing stock levels
- time scheduling
- preventing inconsistent data

You could add this by applying conditions that need to pass before applying a mutation - i.e. only apply a mutation if the following assertions are met.

```auto
mutation {
  transaction {
    actor (func: allofterms(name@en, "jones indiana")) {
      @assert(count(), 0)
    }
  }
  set {
    _:a <name> “Indiana Jones” .
  }
}

```

---

<div class="post-metadata">

**Author:** ![mrjn](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mrjn/32/775_2.png) [@mrjn](https://discuss.dgraph.io/u/mrjn)\
**Post date:** [July 27, 2017, 5:44am UTC](https://discuss.dgraph.io/t/transactions-in-dgraph/1641/2 "2017-07-27T05:44:09Z")

</div>

To do transactions, we’ll have to do distributed transactions, given the fact that Dgraph is a distributed system. And doing distributed txns is a hard problem, that we don’t want to solve at the moment.

For most applications, atomic consistency and durability, that we provide should be sufficient. Dgraph won’t be suited for financial transactions, that’s true.

---

<div class="post-metadata">

**Author:** ![tamethecomplex](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/tamethecomplex/32/496_2.png) [@tamethecomplex](https://discuss.dgraph.io/u/tamethecomplex)\
**Post date:** [October 25, 2017, 12:39pm UTC](https://discuss.dgraph.io/t/transactions-in-dgraph/1641/3 "2017-10-25T12:39:00Z")

</div>

To anyone reading this old thread, Dgraph will have transactions starting in v0.9 per the Dgraph team:

> [@Major changes in v0.9](http://discuss.hypermode.com/t/major-changes-in-v0-9/1886):
>
> v0.9 is introducing support for transactions, which is a MAJOR change throughout the codebase, and significantly affects how users interact with Dgraph. HTTP /query endpoint is going away All the queries and mutations would be done via a transaction API, which is going to be coordinated via Dgraph clients. As such, we have significantly simplified the clients, so that we can easily replicate the functionality and maintain various clients for different languages. Update (1/11) - We have heard …

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/2/2b38fdece2abe5814f2e51bee69d1e67fc304b0a.png) [@system](https://discuss.dgraph.io/u/system)\
**Post date:** [November 28, 2017, 1:00am UTC](https://discuss.dgraph.io/t/transactions-in-dgraph/1641/4 "2017-11-28T01:00:17Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
