edgedb / edgedb-rust

The official Rust binding for EdgeDB
https://edgedb.com
Apache License 2.0
214 stars 26 forks source link

Add a trait to abstract over query executors (Client, Transaction) #339

Closed CodesInChaos closed 1 month ago

CodesInChaos commented 1 month ago

When I write a function to interact with the database, that function generally doesn't care if it runs inside a transaction, or directly on the client. To enable executor agnostic functions, I suggest adding a trait QueryExecutor so such function can take an impl QueryExecutor instead of &Client or &mut Transaction.

This would also simplify the code generated by @ifiokjr's codegen which currently has to generate two methods query and transaction for each query.