0

I noticed by looking at the java source code of the orientdb-gremlin library that it seems to be only a wrapper that gets the gremlin commands and translates into orientdb SQL queries.

I am trying to use gremlin with orientdb in javascript (NodeJs) and for that I am using the gremlin js library. I can connect fine to the gremlin server (I'm using the one shipped with OrientDB 3.0.14) but I could not yet make transactions work for two reasons: 1) gremlin js library does not have the tx() method in the Graph object. 2) I thought: "I can add it there, but let me see first in gremlin console if OrientDB supports opening a transaction from gremlin server". So trying from the gremlin console does not seem to work either (remember that I don't want to use the orientdb-gremlin plugin as in javascript I won't be able to use it):

gremlin> :remote connect tinkerpop.server conf/remote-secure.yaml
gremlin> :> g.tx().open()
gremlin> :> g.tx().isOpen()

This last command results in false, so there is no transaction opened.

Is there any way to span an OrientDB 3.0.14 transaction through gremlin server?

1 Answers1

1

Assuming orientdb-gremlin supports g.tx() (really graph.tx() which is called by g.tx() - i.e. the Graph instance needs to support it) then the only way you use transaction from javascript would be if you submitted string-based scripts to Gremlin Server and did so via session. I think that's potentially why you're not seeing isOpen() return true as you've connected to the server in a sessionless fashion - you can change that by doing:

:remote connect tinkerpop.server conf/remote.yaml session

which is discussed here.

Submitting string-based scripts is not really the recommended way to interact with Gremlin Server. It is a far better development experience to just "write Gremlin" in your native programming language rather than embedding Gremlin in strings. I would reconsider this approach if you can and try not to rely on graph-specific transactions. They make your code far less portable.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135