-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Differentiate results across queries in a transaction #9
Comments
One way I can think of to achieve this is to have the main TransactionStream actually return individual CypherStreams. Each query ( If it's important, maybe there could be an option to "flatten" the result streams into the outer transaction stream, which would get you today's current behavior. |
I was just talking with @wfreeman about this :) It's totally doable, and a feature I plan to add in the near future. You pretty much described the API I had in mind: var transaction = cypher.transaction();
transaction.write({
statement : 'match (n) return n limit 1',
callback : function (stream) { // CypherStream
stream.on('data', function(result) {
console.log(result.n);
})
}
});
transaction.commit() I was also thinking of an idea of a transaction 'channel', which is a factory that automatically manages the creation and committing of transactions for you. The idea being that you can group queries together that don't conflict transactionally and just blast it with queries and it would manage the batching for you automatically. This would allow an application to batch queries even from separate concurrent requests transparently. var transaction = cypher.transaction({ channel: 'create-comments' });
transaction.write({
statement : createCommentsQuery,
callback : handleCreatedComment(s),
})
// will batch all 'create-comments' queries together and auto-commit the transaction after a certain debounce period or max-duration |
Sweet. Looking forward to it! =) P.S. Have you considered making e.g. a gitter.im chatroom for this repo? It's like IRC but much, much better. =) |
I think anyone can make the chatroom. See you there... |
I tried actually and didn't seem to be able to, but I could've easily been doing something wrong... |
Hey @brian-gates, I'm working on thingdom/node-neo4j#143 now, specifically the design of the transactional API that'd wrap this guy. =)
Thinking about a need / use case we at @fiftythree have in our own app, one thing we'd need is the ability to differentiate results across the various queries that make up a transaction.
AFAICT right now, the current cypher-stream design doesn't differentiate. A transaction is a single stream of results, with
data
events that don't tell you which query (statement) each result corresponds to.For example, if the caller doesn't know in advance how many results a query will give, they don't know when the results for one query ends and the next begins.
What are your thoughts for how to achieve that?
The text was updated successfully, but these errors were encountered: