Skip to content

Commit

Permalink
Docs: improve wording explaining ExecuteQuery (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
robsdedude authored Nov 14, 2024
1 parent cb8f9dd commit 2a4727c
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions neo4j/driver_with_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,29 +472,29 @@ func (d *driverWithContext) VerifyAuthentication(ctx context.Context, auth *Auth
// the built-in callback neo4j.ExecuteQueryWithBookmarkManager.
// You can disable bookmark management by passing the neo4j.ExecuteQueryWithoutBookmarkManager callback to ExecuteQuery.
//
// The equivalent functionality of ExecuteQuery can be replicated with pre-existing APIs as follows:
// The equivalent functionality of ExecuteQuery can be replicated with sessions and transaction functions as follows:
//
// // all the error handling bits have been omitted for brevity (do not do this in production!)
// session := driver.NewSession(ctx, neo4j.SessionConfig{
// DatabaseName: "<DATABASE>",
// ImpersonatedUser: "<USER>",
// BookmarkManager: bookmarkManager,
// })
// defer handleClose(ctx, session)
// // session.ExecuteRead is called if the routing is set to neo4j.Read
// result, _ := session.ExecuteWrite(ctx, func(tx neo4j.ManagedTransaction) (any, error) {
// result, _ := tx.Run(ctx, "<CYPHER>", parameters)
// records, _ := result.Collect(ctx) // real implementation does not use Collect
// keys, _ := result.Keys()
// summary, _ := result.Consume(ctx)
// return &neo4j.EagerResult{
// Keys: keys,
// Records: records,
// Summary: summary,
// }, nil
// })
// eagerResult := result.(*neo4j.EagerResult)
// // do something with eagerResult
// // all the error handling bits have been omitted for brevity (do not do this in production!)
// session := driver.NewSession(ctx, neo4j.SessionConfig{
// DatabaseName: "<DATABASE>",
// ImpersonatedUser: "<USER>",
// BookmarkManager: bookmarkManager,
// })
// defer handleClose(ctx, session)
// // session.ExecuteRead is called if the routing is set to neo4j.Read
// result, _ := session.ExecuteWrite(ctx, func(tx neo4j.ManagedTransaction) (any, error) {
// result, _ := tx.Run(ctx, "<CYPHER>", parameters)
// records, _ := result.Collect(ctx) // real implementation does not use Collect
// keys, _ := result.Keys()
// summary, _ := result.Consume(ctx)
// return &neo4j.EagerResult{
// Keys: keys,
// Records: records,
// Summary: summary,
// }, nil
// })
// eagerResult := result.(*neo4j.EagerResult)
// // do something with eagerResult
//
// The available ResultTransformer implementation, EagerResultTransformer, computes an *EagerResult.
// As the latter's name suggests, this is not optimal when the result is made from a large number of records.
Expand Down Expand Up @@ -672,7 +672,6 @@ func ExecuteQueryWithTransactionConfig(configurers ...func(*TransactionConfig))
}
}


// ExecuteQueryWithAuthToken configures neo4j.ExecuteQuery to overwrite the AuthToken for the session.
func ExecuteQueryWithAuthToken(auth AuthToken) ExecuteQueryConfigurationOption {
return func(configuration *ExecuteQueryConfiguration) {
Expand Down

0 comments on commit 2a4727c

Please sign in to comment.