# Db not syncing after transaction

**URL:** <https://forum.datomic.com/t/db-not-syncing-after-transaction/1776>\
**Category:** Datomic Cloud\
**Created:** [February 19, 2021, 11:09am UTC](https://forum.datomic.com/t/db-not-syncing-after-transaction/1776 "2021-02-19T11:09:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikhail](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/mikhail/32/620_2.png) [@Mikhail](https://forum.datomic.com/u/Mikhail)\
**Post date:** [February 19, 2021, 11:09am UTC](https://forum.datomic.com/t/db-not-syncing-after-transaction/1776/1 "2021-02-19T11:09:47Z")

</div>

1. Create a connection and a db:  
(def conn (d/connect client {:db-name “users”}))  
(def db (d/db conn))

2. Add a user:  
(d/transact conn {:tx-data [{:user/name “Some name”}]}))

3. Query for user:  
(d/q '[:find ?ent  
:in $ ?name  
:where [?ent :user/name ?name]]  
db, “Some name”)))

User is not found, unless I redo `(def db (d/db conn))`

Is this the expected behavior?

---

<div class="post-metadata">

**Author:** ![jaret](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/jaret/32/45_2.png) [@jaret](https://forum.datomic.com/u/jaret)\
**Post date:** [February 19, 2021, 1:00pm UTC](https://forum.datomic.com/t/db-not-syncing-after-transaction/1776/2 "2021-02-19T13:00:13Z")

</div>

Yep this is expected behavior. In order to issue a query against a Datomic database, you must retrieve the current database value. A database value is the state of the database **at a given point in time.** You can issue as many queries against that database value as you want, they will always return the same results. This is part of the value add of Datomic :).

You can always get the current DB in your query by doing the following:

```auto
(d/q '[:find ?ent
:in $ ?name
:where [?ent :user/name ?name]]
(d/db conn), “Some name”)))

```

---

<div class="post-metadata">

**Author:** ![jmshelby](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/jmshelby/32/437_2.png) [@jmshelby](https://forum.datomic.com/u/jmshelby)\
**Post date:** [February 19, 2021, 5:54pm UTC](https://forum.datomic.com/t/db-not-syncing-after-transaction/1776/3 "2021-02-19T17:54:54Z")

</div>

In addition to what @jaret said, it’s often advantageous to use the `:db-after` provided by `d/transact` fn return map, when a flow of logic needs to transact data and run queries on the result of that data

---

<div class="post-metadata">

**Author:** ![Mikhail](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/mikhail/32/620_2.png) [@Mikhail](https://forum.datomic.com/u/Mikhail)\
**Post date:** [February 22, 2021, 1:24pm UTC](https://forum.datomic.com/t/db-not-syncing-after-transaction/1776/4 "2021-02-22T13:24:24Z")

</div>

Thank you, it became a little clearer 🙂
