From 2a4727c6e477dd4c37a206d34567b8e216b41a39 Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Thu, 14 Nov 2024 13:10:32 +0100 Subject: [PATCH] Docs: improve wording explaining ExecuteQuery (#609) --- neo4j/driver_with_context.go | 45 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/neo4j/driver_with_context.go b/neo4j/driver_with_context.go index 60b489ec..6cff2cb5 100644 --- a/neo4j/driver_with_context.go +++ b/neo4j/driver_with_context.go @@ -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: "", -// ImpersonatedUser: "", -// 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, "", 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: "", +// ImpersonatedUser: "", +// 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, "", 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. @@ -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) {