In the doc of transaction, can I use results from makeFirstQuery() in makeSecondQuery() 's params?
linonetwo opened this issue · 1 comments
linonetwo commented
in transaction it reads:
function makeFirstQuery() {
tx.cypher({
query: '...',
params {...},
}, makeSecondQuery);
}
function makeSecondQuery(err, results) {
if (err) throw err;
// ...some application logic...
tx.cypher({
query: '...',
params: {...},
}, finish);
}
function finish(err, results) {
if (err) throw err;
// ...some application logic...
tx.commit(done); // or tx.rollback(done);
}
function done(err) {
if (err) throw err;
// At this point, the transaction has been committed.
}
can I use results from makeFirstQuery() in makeSecondQuery() 's params?
And what does done() used for? It doesn't receive a results parameter.
aseemk commented
Hi @linonetwo,
can I use results from makeFirstQuery() in makeSecondQuery() 's params?
Absolutely!
And what does done() used for? It doesn't receive a results parameter.
done
is just the callback for tx.commit
. tx.commit
(and tx.rollback
) callbacks don't receive any results. They're just a way for you to know whether the commit (or rollback) was successful. E.g. you might want to wait for this before responding to a request.
Hope this helps! Feel free to ask any more q's.