Replies: 3 comments 3 replies
-
Since v5.7.0, we gradually started introducing new packages to fight the cruft.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
The public
Future releases will likely move other bits out of the |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi @fbiville is any help wanted with this refactor above? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I just extracted some statistics about the
neo4j
package that you know and love.This is what it looks like on the
5.0
branch:Note: The results may not be 100% accurate, as I wrote an AST visitor in a pretty quick'n'dirty way.
For one of the next major versions, I was thinking that maybe it's time to put some APIs to their own package.
Why? I believe the current way of stuffing everything into the same package hurts discoverability.
Ideally, I would love to keep
neo4j
only for the basic Driver elements you'll find in all official drivers (and some community ones) as well:Driver
(will be gone in 6.0) /DriverWithContext
and their siblings (AuthToken
,Config
, ...)Session
(will be gone in 6.0) /SessionWithContext
and their siblings (SessionConfig
,TransactionConfig
, ...)Transaction
(will be gone in 6.0) /ExplicitTransaction
/ManagedTransaction
Result
(will be gone in 6.0) /ResultWithContext
and their siblings (ResultSummary
, ...)That would leave helpers out and they would need a new home (or even new homes if they don't really belong together).
Here is a short list of the helpers we've got today:
Record type assertion helpers:
func AsRecord(from any, err error) (*Record, error)
func AsRecords(from any, err error) ([]*Record, error)
Result aggregation helpers:
func Collect(result Result, err error) ([]*Record, error)
func CollectTWithContext[T any](ctx context.Context, result ResultWithContext, mapper func(*Record)) ([]T, error)
func CollectT[T any](result Result, mapper func(*Record)) ([]T, error)
func CollectWithContext(ctx context.Context, result ResultWithContext, err error) ([]*Record, error)
func Single(result Result, err error) (*Record, error)
func SingleTWithContext[T any](ctx context.Context, result ResultWithContext, mapper func(*Record)) (T, error)
func SingleT[T any](result Result, mapper func(*Record)) (T, error)
Transaction function generic helpers:
func ExecuteRead[T any](ctx context.Context, session SessionWithContext, work ManagedTransactionWorkT[T], configurers ...func(config *TransactionConfig)) (T, error)
func ExecuteWrite[T any](ctx context.Context, session SessionWithContext, work ManagedTransactionWorkT[T], configurers ...func(config *TransactionConfig)) (T, error)
Record generic mapping helpers and their associated type constraint:
func GetProperty[T PropertyValue](entity Entity, key string) (T, error)
func GetRecordValue[T RecordValue](record *Record, key string) (T, bool, error)
Arguably, the date/time helpers could be moved too:
func DateOf(t time.Time) Date
func DurationOf(months int64, nanos int) Duration
func LocalDateTimeOf(t time.Time) LocalDateTime
func LocalTimeOf(t time.Time) LocalTime
What do you think? How has been your experience with navigating the Go driver API so far?
I'm interested in your opinion regardless of your level of experience with the Go driver ;)
Beta Was this translation helpful? Give feedback.
All reactions