- 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
[DataMapper] Have a common API for datamapper to query tuples #375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|  | @@ -207,41 +207,6 @@ class DataMapper: public std::enable_shared_from_this<DataMapper> | |||||
| template <typename Record, typename... InputParameters> | ||||||
| std::vector<Record> Query(SqlSelectQueryBuilder::ComposedQuery const& selectQuery, InputParameters&&... inputParameters); | ||||||
|  | ||||||
| /// Queries multiple records and returns them as a vector of std::tuple of the given record types. | ||||||
| /// This can be used to query multiple record types in a single query. | ||||||
| /// | ||||||
| /// example: | ||||||
| /// @code | ||||||
| /// struct Person | ||||||
| /// { | ||||||
| /// int id; | ||||||
| /// std::string name; | ||||||
| /// std::string email; | ||||||
| /// std::string phone; | ||||||
| /// }; | ||||||
| /// struct Address | ||||||
| /// { | ||||||
| /// int id; | ||||||
| /// std::string address; | ||||||
| /// std::string city; | ||||||
| /// std::string country; | ||||||
| /// }; | ||||||
| /// void example(DataMapper& dm) | ||||||
| /// { | ||||||
| /// auto const sqlQueryString = R"(SELECT p.*, a.* FROM "Person" p INNER JOIN "Address" a ON p.id = a.id WHERE p.city = | ||||||
| /// Berlin AND a.country = Germany)"; | ||||||
| /// auto const records = dm.QueryToTuple<Person, Address>(sqlQueryString); | ||||||
| /// for (auto const& [person, address] : records) | ||||||
| /// { | ||||||
| /// std::println("Person: {}", DataMapper::Inspect(person)); | ||||||
| /// std::println("Address: {}", DataMapper::Inspect(address)); | ||||||
| /// } | ||||||
| /// } | ||||||
| /// @endcode | ||||||
| template <typename... Records> | ||||||
| requires DataMapperRecords<Records...> | ||||||
| std::vector<std::tuple<Records...>> QueryToTuple(SqlSelectQueryBuilder::ComposedQuery const& selectQuery); | ||||||
|  | ||||||
| /// Queries multiple records from the database, based on the given query. | ||||||
| /// | ||||||
| /// @param sqlQueryString The SQL query string to execute. | ||||||
|  | @@ -303,7 +268,7 @@ class DataMapper: public std::enable_shared_from_this<DataMapper> | |||||
|  | ||||||
| /// Queries records of different types from the database, based on the given query. | ||||||
| /// User can constructed query that selects columns from the multiple tables | ||||||
| /// this function is uset to get result of the | ||||||
| /// this function is uset to get result of the query | ||||||
| /// | ||||||
| /// example: | ||||||
| /// @code | ||||||
|  | @@ -325,16 +290,13 @@ class DataMapper: public std::enable_shared_from_this<DataMapper> | |||||
| /// { | ||||||
| /// // do something with elementA and elementC | ||||||
| /// } | ||||||
| template <typename FirstRecord, typename NextRecord, typename... InputParameters> | ||||||
| requires DataMapperRecord<FirstRecord> && DataMapperRecord<NextRecord> | ||||||
| // TODO : need more generic one and we also have queryToTuple | ||||||
| std::vector<std::tuple<FirstRecord, NextRecord>> Query(SqlSelectQueryBuilder::ComposedQuery const& selectQuery, | ||||||
| InputParameters&&... inputParameters); | ||||||
| template <typename First, typename Second, typename... Rest> | ||||||
| requires DataMapperRecords<First> && DataMapperRecords<Second> && DataMapperRecords<Rest...> | ||||||
| 
     | ||||||
| requires DataMapperRecords<First> && DataMapperRecords<Second> && DataMapperRecords<Rest...> | |
| requires DataMapperRecord<First> && DataMapperRecord<Second> && DataMapperRecord<Rest...> | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'uset' to 'used'.