4 ms·
Isn't what you actually want from that something like one of the following? HashMap<User, (Vec<Post>, Vec<Comment>)> HashMap<i32, (User, Vec<Post>, Vec
by pedrocr 9y ago
Isn't what you actually want from that something like one of the following?
HashMap<User, (Vec<Post>, Vec<Comment>)>
HashMap<i32, (User, Vec<Post>, Vec<Comment>)>
Vec<(User, Vec<Post>, Vec<Comment>)>
- kbenson 9y agoI think Comments are children of Posts, so ideally there would be a way to easily access all comments by post_id. Ideally, comments would be keyed to their post, and the post would be keyed to the user. On rethinking this though, I'm wondering if the more performant way might be to provide a helper function that iterates over all returned rows, identifies when one record type in the result ends and another begins (the same steps you have to do to condense), but just executes a registered callback at that time. E.g. user_begin, user_end, post_begin, post_end, etc. Although I should probably read up more on how Java/C/C# do this before spouting my half formed ideas about an area I'm not really informed in.... ;)