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.

What way to choose to communicate with the database?

pavloN
Node Clone

Hi! I have written a node js app.
This approach being used to write/read data from DB:

async function startQuery(query) {
const session = driver.session();
return session
.run(q)
.then(result => {
session.close();
return result;
})
.catch(error => {
session.close();
});
}

I usually use async/await in code.
What about this way? Or better to use writeTransaction and readTransaction with txc (without async txc)?

async function newQ(query) {
const session = driver.session();
const write = session.writeTransaction(async txc => {
var result = await txc.
return result;
});
write
.then(namesArray => {
console.log(namesArray);
})
.catch(error => {
console.log(error);
})
.then(() => session.close());
}

0 REPLIES 0