简体   繁体   中英

gremlin javascript transactions

Querying orientdb using gremlin in nodejs works ok but with updates I really need transactions

I cannot find how to use them in gremlin for javascript - are they implemented?

I expected them to be implemented or documented they are not. Any one know for sure before I use submitted script which I want to avoid.

Alternatively is there documentation or a guide on how to submit bytecode based requests?

Except where the documentation in the "Submitting Scripts" subsection all of the remaining documentation involves bytecode based submissions:

http://tinkerpop.apache.org/docs/current/reference/#gremlin-javascript

Bytecode based requests are transaction managed on the server where one request is one transaction - meaning there is a commit on success or a rollback on failure. The semantics of rollback are dictated by the underlying graph database which determines whether all mutated state is returned to what it was before the request or not. There is no way to extend transactions beyond a single request with bytecode based requests.

The only way to do transactions that extend over multiple requests is with script based submissions that use a session. I don't think it's even documented how to use sessions (outside of Java ) as it is not a recommended approach for a variety of reasons (code portability, bytecode is the future and scripts will eventually fall to the wayside, scripts have security implications, etc).

I recommend that you rethink your application such that you do not need to implicitly utilize transactions and simply allow the server to handle such things for you.

As of most recent releases at 3.5.0/3.4.11, the guidance for scripts and transactions have changed. It is now possible to do bytecode based transactions in 3.5.0 using Java. This feature will be extended to other programming languages, like javascript, along the 3.5.x release line. 3.5.0 also introduces what will become a better more secure method for processing scripts with the gremlin-language module so TinkerPop has largely changed direction with respect to the position that Gremlin scripts will some day be removed.

While there may yet be references in the documentation to preferring bytecode requests, you should do so because it is easier to write Gremlin in Javascript that way (as opposed to writing Gremlin as strings) and not because of concern for script support being removed. The only potential limitation to scripts we might see in the future could be removing the ability to process scripts that include code other than Gremlin (ie a script that has both Gremlin and Groovy code). Depending on the graph database you are using you may find that such a feature is not even available to you now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM