Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-2343

Update docs for withTransaction

    • Type: Icon: Task Task
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Lambda
    • None

      https://mongodb.github.io/node-mongodb-native/3.3/api/ClientSession.html#withTransaction says: 
      IMPORTANT: This method requires the user to return a Promise, all lambdas that do not
      return a Promise will result in undefined behavior.

      The first Node.js example on https://docs.mongodb.com/manual/core/transactions/index.html says:

      // Note: The callback for withTransaction MUST be async and/or return a Promise.

      The example uses an async function and does not return a Promise.  I've tried this out and it's working for me. 

       

      I think the driver docs need to be updated to indicate the function can be async or return a promise. 

            Assignee:
            matt.broadstone@mongodb.com Matt Broadstone
            Reporter:
            lauren.schaefer@mongodb.com Lauren Schaefer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: