brikteknologier / seraph

A thin and familiar layer between node and neo4j's REST api.
MIT License
309 stars 59 forks source link

Support for rolling back transactions. #167

Open dkushner opened 9 years ago

dkushner commented 9 years ago

Seraph has excellent support for transactions, something that is sorely missing from most of the other Neo4j clients in the space. However, one of the most powerful applications of these transactions is the ability to manually roll back unwanted change sets from the client. For this reason, the HTTP API provides for a DELETE /db/data/transaction/:txId route. Seraph should likewise support the rolling back of transactions that it has created.

dkushner commented 9 years ago

My proposal is as follows:

var txn = db.batch();

txn.save({ title: 'Kaikki Askeleet' });
txn.save({ title: 'Sinä Nukut Siinä' });
txn.save({ title: 'Pohjanmaa' });

txn.rollback(function(err, results) {
  /* results -> [] */
});
db.batch(function(txn) {
  txn.save({ title: 'Kaikki Askeleet' });
  txn.save({ title: 'Sinä Nukut Siinä' });
  txn.save({ title: 'Pohjanmaa' });

  txn.rollback();
}, function(err, results) {
  /* results -> [] */
});

@jonpacker, how does this look to you?

jonpacker commented 9 years ago

I would really love this to be the case, but batch is using the batching API, not the transactional cypher API, which is the API that supports rollbacks. Ultimately I do want to support the transactional cypher API, and rollbacks will of course be a part of that, but I'm having great difficulty finding the time for it. I'll leave this open as a bit of a nag for me to get around to it :)