Skip to content

Commit 2a4727c

Browse files
authored
Docs: improve wording explaining ExecuteQuery (#609)
1 parent cb8f9dd commit 2a4727c

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

neo4j/driver_with_context.go

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -472,29 +472,29 @@ func (d *driverWithContext) VerifyAuthentication(ctx context.Context, auth *Auth
472472
// the built-in callback neo4j.ExecuteQueryWithBookmarkManager.
473473
// You can disable bookmark management by passing the neo4j.ExecuteQueryWithoutBookmarkManager callback to ExecuteQuery.
474474
//
475-
// The equivalent functionality of ExecuteQuery can be replicated with pre-existing APIs as follows:
475+
// The equivalent functionality of ExecuteQuery can be replicated with sessions and transaction functions as follows:
476476
//
477-
// // all the error handling bits have been omitted for brevity (do not do this in production!)
478-
// session := driver.NewSession(ctx, neo4j.SessionConfig{
479-
// DatabaseName: "<DATABASE>",
480-
// ImpersonatedUser: "<USER>",
481-
// BookmarkManager: bookmarkManager,
482-
// })
483-
// defer handleClose(ctx, session)
484-
// // session.ExecuteRead is called if the routing is set to neo4j.Read
485-
// result, _ := session.ExecuteWrite(ctx, func(tx neo4j.ManagedTransaction) (any, error) {
486-
// result, _ := tx.Run(ctx, "<CYPHER>", parameters)
487-
// records, _ := result.Collect(ctx) // real implementation does not use Collect
488-
// keys, _ := result.Keys()
489-
// summary, _ := result.Consume(ctx)
490-
// return &neo4j.EagerResult{
491-
// Keys: keys,
492-
// Records: records,
493-
// Summary: summary,
494-
// }, nil
495-
// })
496-
// eagerResult := result.(*neo4j.EagerResult)
497-
// // do something with eagerResult
477+
// // all the error handling bits have been omitted for brevity (do not do this in production!)
478+
// session := driver.NewSession(ctx, neo4j.SessionConfig{
479+
// DatabaseName: "<DATABASE>",
480+
// ImpersonatedUser: "<USER>",
481+
// BookmarkManager: bookmarkManager,
482+
// })
483+
// defer handleClose(ctx, session)
484+
// // session.ExecuteRead is called if the routing is set to neo4j.Read
485+
// result, _ := session.ExecuteWrite(ctx, func(tx neo4j.ManagedTransaction) (any, error) {
486+
// result, _ := tx.Run(ctx, "<CYPHER>", parameters)
487+
// records, _ := result.Collect(ctx) // real implementation does not use Collect
488+
// keys, _ := result.Keys()
489+
// summary, _ := result.Consume(ctx)
490+
// return &neo4j.EagerResult{
491+
// Keys: keys,
492+
// Records: records,
493+
// Summary: summary,
494+
// }, nil
495+
// })
496+
// eagerResult := result.(*neo4j.EagerResult)
497+
// // do something with eagerResult
498498
//
499499
// The available ResultTransformer implementation, EagerResultTransformer, computes an *EagerResult.
500500
// As the latter's name suggests, this is not optimal when the result is made from a large number of records.
@@ -672,7 +672,6 @@ func ExecuteQueryWithTransactionConfig(configurers ...func(*TransactionConfig))
672672
}
673673
}
674674

675-
676675
// ExecuteQueryWithAuthToken configures neo4j.ExecuteQuery to overwrite the AuthToken for the session.
677676
func ExecuteQueryWithAuthToken(auth AuthToken) ExecuteQueryConfigurationOption {
678677
return func(configuration *ExecuteQueryConfiguration) {

0 commit comments

Comments
 (0)