Since await
does not work inside Array.map
or Array.reduce
, can you do something like the following or would this be considered misuse of Promise.all
? Normally, neo4j.session()
would be awaited.
// inside a function
const QUERY = 'MATCH (n) RETURN n'
const argsArray = [{ sample: 'sadf' }, { sample: 'sadf' }, { sample: 'sadf' }]
const runQueries = argsArray.map(obj => neo4j.session.run(QUERY, obj.sample))
await Promise.all(runQueries)
.then(results => results.forEach(result => console.log(result)))
Promise.all(runQueries).then(console.log)
is cleaner – Brainwashing