Use result transformer
Select the correct result transformer to use for eager loading of all results.
go
result, err := driver.ExecuteQuery(ctx,
"MATCH (p:Person) RETURN p.name AS name",
nil,
neo4j./*select:EagerResultTransformer*/,
)
-
❏ LazyResultTransformer
-
✓ EagerResultTransformer
-
❏ StreamResultTransformer
-
❏ AllResultTransformer
Hint
Use the transformer that loads all results into memory at once.
Solution
The correct answer is EagerResultTransformer
.
go
result, err := driver.ExecuteQuery(ctx,
"MATCH (p:Person) RETURN p.name AS name",
nil,
neo4j.EagerResultTransformer,
)
EagerResultTransformer
loads all results into memory at once, which is useful for smaller result sets or when you need to access all results immediately.
Lesson Summary
In this lesson, you learned how to use result transformers to customize the output format of your queries.
You have now completed the first module on the Neo4j Go Driver. In the next module, you will learn about handling different types of results.