Article DetailsDetailsHelp DetailsThe Neo4j official Go 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: session := driver.NewSession(neo4j.SessionConfig{}) defer session.Close() _, err = session.ReadTransaction(func(tx neo4j.Transaction) (interface{}, error) { getActorsRead := ` MATCH (p:Person)-[:ACTED_IN]->(m) WHERE toLower(m.title) CONTAINS toLower($title) RETURN DISTINCT p.name as actorsTx` result, err := tx.Run(getActorsRead, map[string]interface{}{ "title": "matrix", }) if err != nil { return nil, err } for result.Next() { fmt.Printf("Found actor: '%s' \n", result.Record().Values[0].(string)) } return nil, result.Err() }) For Version 5 of the driver, you need to use the ExecuteRead function instead: session := driver.NewSession(neo4j.SessionConfig{}) defer session.Close() _, err = session.ExecuteRead(func(tx neo4j.Transaction) (interface{}, error) { getActorsRead := ` MATCH (p:Person)-[:ACTED_IN]->(m) WHERE toLower(m.title) CONTAINS toLower($title) RETURN DISTINCT p.name as actorsTx` result, err := tx.Run(getActorsRead, map[string]interface{}{ "title": "matrix", }) if err != nil { return nil, err } for result.Next() { fmt.Printf("Found actor: '%s' \n", result.Record().Values[0].(string)) } return nil, result.Err() }) InformationTitleHow to mark queries as READ transactions in the official Neo4j Go driver?Article Created Date3/15/2024, 10:57 PMURL Name7182736436371-How-to-mark-queries-as-READ-transactions-in-the-official-Neo4j-Go-driverLast Modified Date3/20/2024, 7:07 PM