cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Javascript neo4j-driver and async function

bruno_c
Node Link

Up to now,
I managed to have my function that run the queries being able to return a result immediately.
so the structure of my functions where
var session = driver.session();
return session.run([QUERY]).then(result=> return result.record.map ....)

I now have a bigger query and maybe for that reason, I end up having the query function return a Premise
I switched then to an async function with the following structure

var session = driver.session();
await session.run([QUERY]).then(result=> results= result.record.map ....)
return results

But then I get regeneratorRuntime is not defined at runtime in the console of the browser.

As environment config, I have the one of the sampe movies-javascript-bolt-master

Thank You

1 REPLY 1

You cab do something like this

let query = 'query'
let param = {params }

try {
  const result = await session.run(query, param)
  if (result.records.length != 0) {
    console.log('operation successful ')

  } else {
    console.log('operation did not return any result ')

  }
} catch (error) {

  console.log('exception occure', error)
  throw error;
} finally {
  await session.close()
}