Skip to content

Move done() to transaction.done(); #207

Closed

Description

@ryanseys

From the docs:

dataset.runInTransaction(function(transaction, done) {
  // From the `transaction` object, execute dataset methods as usual.
  // Call `done` when you're ready to commit all of the changes.
  transaction.get(dataset.key('Company', 123), function(err, entity) {
    if (err) {
      transaction.rollback(done);
      return;
    }

    done();
  });
}, function(err) {});

Any reason why done is separate from transaction?
Can we replace done with transaction.done?

Also, what does calling rollback with the done function do? Shouldn't it do this by default? It could if we can just call this.done() from within Transaction.prototype.rollback() ?

Activity

  1. stephenplusplus commented on Sep 12, 2014

    @stephenplusplus
    Contributor

    Any reason why done is separate from transaction?
    Can we replace done with transaction.done?

    It's common to see flow control callbacks come as their own variable. I'd like to stay with done.

    Also, what does calling rollback with the done function do? Shouldn't it do this by default? It could if we can just call this.done() from within Transaction.prototype.rollback() ?

    It could do it by default, but the user should understand the flow. "When rollback is done, this function is exiting. My callback to runInTransaction will be next."

  2. ryanseys commented on Sep 12, 2014

    @ryanseys
    ContributorAuthor

    This makes sense. I'm closing this.

  3. added this to the Datastore Stable milestone on Feb 2, 2015
  4. 41 remaining items

  5. added a commit that references this issue on Mar 5, 2026
  6. added a commit that references this issue on Mar 17, 2026
  7. added a commit that references this issue on Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.api: datastoreIssues related to the Datastore API.triage meI really want to be triaged.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions