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

Pass through results of given lambda in withTransaction and withSession

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: Not Applicable
    • Fix Version/s: None
    • Component/s: core

      Description

      The provided withTransaction and withSession helpers make running transactions very simple, but it's difficult to get the results of the operation back.

      Both functions take a lambda as an argument that must return a Promise, but the functions don't pass through the value that the promise resolves to. This means that I need to create a wrapper function like this in order to get the return value:

      runTransaction(writeFunc) {
       
      	let writeResults = null;
       
      	const txnFunc = session => (
       
      		writeFunc(session)
      			.then((results) => { writeResults = results; })
      	);
       
      	return this.client.withSession(session => session.withTransaction(txnFunc)))
      		.then(() => {
       
      			return writeResults;
      		});
      }
      

      It's not the end of the world, but it would be nice if these functions could just pass through the results.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            dominicp Dominic
            Participants:
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated: