You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I want join the statements to programmatically build queries with transaction such as like below.
// ...let nested_foos = [Foo{bars:[Bar{ ...},Bar{ ...},Bar{ ...}]},,,];letmut stmt = a_connection.prepare(["begin transaction;"]);for foo in nested_foos {let bars = foo.bars.clone().iter().map( ...);for bar in bars {
stmt.join("insert into bars values <map iterative values here>");}}
stmt.join("commit;");// ...
It's really useful when I persist denormalized objects into the DB.
Or perhaps it also works to provide a .transaction() method like other libraries and supporting array query #38.
But I think the above approach is slightly better because it's more like generic (and also, currently we can't await the asynchronous process in the lambda).
Is there any solution? It's technically possible by using format!() macro or some template engines, for example. But format!() macro is unrealistic when normalizing complex objects. And I feel using template engines is too much for this purpose.
The text was updated successfully, but these errors were encountered:
Hello, there is no any abstraction to do what your pseudo-code suggests. I would indeed just have a loop but with one prepared statements to which I would keep on binding different values taken from the objects iterated over. Please see the examples in the readme. If you are looking for transactions, please take a look at this closed PR: #35.
Hello, I want join the statements to programmatically build queries with transaction such as like below.
It's really useful when I persist denormalized objects into the DB.
Or perhaps it also works to provide a
.transaction()
method like other libraries and supporting array query #38.But I think the above approach is slightly better because it's more like generic (and also, currently we can't await the asynchronous process in the lambda).
Is there any solution? It's technically possible by using format!() macro or some template engines, for example. But format!() macro is unrealistic when normalizing complex objects. And I feel using template engines is too much for this purpose.
The text was updated successfully, but these errors were encountered: