5#include "../SqlConnection.hpp"
6#include "../SqlQueryFormatter.hpp"
7#include "../SqlStatement.hpp"
9#include "BelongsTo.hpp"
30template <
typename Record,
typename Derived, DataMapperOptions QueryOptions = {}>
39 friend class SqlWhereClauseBuilder<Derived>;
41 LIGHTWEIGHT_FORCE_INLINE SqlSearchCondition& SearchCondition()
noexcept
43 return this->_query.searchCondition;
46 [[nodiscard]] LIGHTWEIGHT_FORCE_INLINE
SqlQueryFormatter const& Formatter()
const noexcept
57 [[nodiscard]]
bool Exist();
60 [[nodiscard]]
size_t Count();
63 [[nodiscard]] std::vector<Record> All();
81#if defined(LIGHTWEIGHT_CXX26_REFLECTION)
82 requires(is_aggregate_type(parent_of(
Field)))
84 requires std::is_member_object_pointer_v<
decltype(
Field)>
86 [[nodiscard]]
auto All() -> std::vector<ReferencedFieldTypeOf<Field>>;
101 template <
auto... ReferencedFields>
102 requires(
sizeof...(ReferencedFields) >= 2)
103 [[nodiscard]]
auto All() -> std::vector<Record>;
106 [[nodiscard]] std::optional<Record> First();
113 template <auto Field>
114#if defined(LIGHTWEIGHT_CXX26_REFLECTION)
115 requires(is_aggregate_type(parent_of(
Field)))
117 requires std::is_member_object_pointer_v<
decltype(
Field)>
119 auto First() -> std::optional<ReferencedFieldTypeOf<Field>>;
126 template <
auto... ReferencedFields>
127 requires(
sizeof...(ReferencedFields) >= 2)
128 [[nodiscard]]
auto First() -> std::optional<Record>;
131 [[nodiscard]] std::vector<Record> First(
size_t n);
133 template <
auto... ReferencedFields>
134 [[nodiscard]] std::vector<Record> First(
size_t n);
137 [[nodiscard]] std::vector<Record> Range(
size_t offset,
size_t limit);
139 template <
auto... ReferencedFields>
140 [[nodiscard]] std::vector<Record> Range(
size_t offset,
size_t limit);
146template <
typename Record, DataMapperOptions QueryOptions>
156 dm, std::move(fields)
161 static void ReadResults(SqlServerType sqlServerType,
SqlResultCursor reader, std::vector<Record>* records);
162 static void ReadResult(SqlServerType sqlServerType,
SqlResultCursor reader, std::optional<Record>* optionalRecord);
170template <
typename FirstRecord,
typename SecondRecord, DataMapperOptions QueryOptions>
173 SqlAllFieldsQueryBuilder<std::tuple<FirstRecord, SecondRecord>, QueryOptions>,
177 using RecordType = std::tuple<FirstRecord, SecondRecord>;
183 dm, std::move(fields)
188 static void ReadResults(SqlServerType sqlServerType, SqlResultCursor reader, std::vector<RecordType>* records);
Main API for mapping records to and from the database using high level C++ syntax.
Represents a query builder that retrieves all fields of a record.
auto First() -> std::optional< Record >
Executes a SELECT query for the first record found and returns it with only the specified fields popu...
auto All() -> std::vector< Record >
Executes a SELECT query and returns all records found for the specified field, only having the specif...
API for reading an SQL query result set.
bool loadRelations
This is the default behavior since compilation times significantly increase otherwise.
Represents a single column in a table.