Max' version in neography is similar: https://github.com/maxdemarzi/neography/wiki/Transactions
On Sun, Jan 26, 2014 at 10:50 AM, Nigel Small <[email protected]> wrote: > Hi Gorka > > If it helps, have a look at the way I've presented the transactional > endpoint in py2neo: > > https://github.com/nigelsmall/py2neo/blob/master/py2neo/cypher.py#L108 > > At the top level is a *Session* object that maintains the root URI for > the database then, from that, transactions can be created. For each > transaction, it's possible to add any number of statements and send these > to the server for execution or commit/rollback as required. The precise > REST endpoint used varies depending on the order in which executes and > commits are received. > > For example: > > from py2neo import cypher > session = cypher.Session("http://localhost:7474")tx = > session.create_transaction() > # send three statements to for execution but leave the transaction > opentx.append("MERGE (a:Person {name:'Alice'})")tx.append("MERGE (b:Person > {name:'Bob'})")tx.append("CREATE UNIQUE (a)-[:KNOWS]->(b)")tx.execute() > # send another three statements and commit the transactiontx.append("MERGE > (c:Person {name:'Carol'})")tx.append("MERGE (d:Person > {name:'Dave'})")tx.append("CREATE UNIQUE (c)-[:KNOWS]->(d)")tx.commit() > > Each *execute()* or *commit()* method call will use one of four possible > URIs: > > - *BEGIN* -> /db/data/transaction > - *BEGIN_COMMIT* -> /db/data/transaction/commit > - *EXECUTE* -> /db/data/transaction/{id} > - *COMMIT* -> /db/data/transaction/{id}/commit > > If the transaction ID is unknown (because no calls have previously been > made) then the *execute()* method will use the *BEGIN* endpoint, > otherwise it will use *EXECUTE*. Similarly, the *commit()* method will > use either *BEGIN_COMMIT* or *COMMIT*. The actual code behind these > methods is here: > > https://github.com/nigelsmall/py2neo/blob/master/py2neo/cypher.py#L226 > > By the way, I can't claim credit for this approach. It was inspired by a > conversation with Tatham Oddie, author of the .NET driver, at GraphConnect > SF last year :-) > > Cheers > Nige > > > On 26 January 2014 05:40, Michael Hunger <[email protected] > > wrote: > >> Thanks a lot for your engagement! What language / environment are you >> developing the driver for? >> >> This is most efficient: >> - Multiple queries directly to /transaction/commit (creating a new >> transaction each one?) >> >> It depends on the usage though, if decisions for the following queries >> are made based on the results of previous ones then you'll probably want to >> support multiple requests within a single tx. >> >> Cheers >> >> Michael >> >> >> >> On Sat, Jan 25, 2014 at 11:42 AM, Gorka Lertxundi >> <[email protected]>wrote: >> >>> I started developing a neo4j client and when I reach to the >>> transactional endpoint there's something i'm not sure about: >>> >>> Which is the best option regarding to multiple 'MATCH' statements? (no >>> updates, no creates): >>> - Multiple queries directly to /transaction/commit (creating a new >>> transaction each one?) >>> - Create a transaction and then do MATCHes in it /transaction/5 (do >>> commit :\ after all?) >>> >>> rgds, >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Neo4j" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Neo4j" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- > You received this message because you are subscribed to the Google Groups > "Neo4j" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
