How to mark queries as READ transactions in the official Neo4j JavaScript driver?Mar 20, 2024Knowledge
Article DetailsDetailsHelp DetailsThe Neo4j JavaScript driver's session object has a readTransaction method that you can use for marking read queries explicitly. For Version 4 of the driver, the below example using the readTransaction function is correct: var movieName = 'matrix' const readQuery = `MATCH (p:Person)-[:ACTED_IN]->(m)\ WHERE toLower(m.title) CONTAINS toLower($title) \ RETURN DISTINCT p.name as actorsTx` const readResult = await session.readTransaction(tx => tx.run(readQuery, { title: movieName }) ) readResult.records.forEach(record => { console.log(`Found actor: ${record.get('actorsTx')}`) }) For Version 5 of the driver, you need to use the executeRead function instead: var movieName = 'matrix' const readQuery = `MATCH (p:Person)-[:ACTED_IN]->(m)\ WHERE toLower(m.title) CONTAINS toLower($title) \ RETURN DISTINCT p.name as actorsTx` const readResult = await session.executeRead(tx => tx.run(readQuery, { title: movieName }) ) readResult.records.forEach(record => { console.log(`Found actor: ${record.get('actorsTx')}`) })InformationTitleHow to mark queries as READ transactions in the official Neo4j JavaScript driver?Article Created Date3/15/2024, 10:57 PMURL Name7182361642771-How-to-mark-queries-as-READ-transactions-in-the-official-Neo4j-JavaScript-driverLast Modified Date3/20/2024, 7:08 PM