Query a node after insert without commit using the same transaction

Hi

Is transactions support access to added/altered data before it is committed, while using the same transaction object?

I am inserting a node without commit and want to query data back by uid using the same transaction object.

I know the node was inserted since I am getting back uid in response, but query always return empty result.

I know my query is working. I did verify the query by committing the transaction and getting the data back.

But, query seems can’t see a new data within the same transaction.

Thanks
Dmitriy

Nope.

True.

True again.

The way Dgraph works needs an extra transaction. Cuz the data needs to be distributed(some cases replicated) across the cluster. Without that confirmation, you can’t query the data.

In theory, would be possible to get the data from the cluster “memory”(Similar to a “MEMPOOL” from Bitcoin core). Just, in theory, cuz in practice that would be a bit complicated to implement(need more changes in the procedures) BUT in the end, there’s no usability to support such idea. As you can just verify the data before sending it to the transaction or just commit it.

Thank you for you answers, and I have one more question.
Suppose I added 2 nodes using the same transaction, and need to add 3-rd node that has links to other 2 nodes.
Does this require to commit first 2 nodes before I can add 3-rd node that has links to them?

Nope, you can do as many links and additions in a single transaction you wish before committing. You have to pay attention to existing UIDs and use the same blank nodes in the transaction context.

1 Like