Lightweight 0.20260617.0
Loading...
Searching...
No Matches
Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions > Class Template Reference

#include <QueryBuilders.hpp>

Inheritance diagram for Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >:
Lightweight::SqlAllFieldsQueryBuilder< Record, QueryOptions, Execution >

Public Member Functions

auto Exist ()
 
auto Count ()
 Executes a SELECT COUNT query and returns the number of records found.
 
auto All ()
 Executes a SELECT query and returns all records found.
 
auto Delete ()
 Executes a DELETE query.
 
template<auto Field>
requires std::is_member_object_pointer_v<decltype(Field)>
auto All ()
 Executes a SELECT query and returns all records found for the specified field.
 
template<auto... ReferencedFields>
requires (sizeof...(ReferencedFields) >= 2)
auto All ()
 Executes a SELECT query and returns all records found for the specified field, only having the specified fields queried and populated.
 
auto First ()
 Executes a SELECT query for the first record found and returns it.
 
template<auto Field>
requires std::is_member_object_pointer_v<decltype(Field)>
auto First ()
 Executes the query to get a single scalar value from the first record found.
 
template<auto... ReferencedFields>
requires (sizeof...(ReferencedFields) >= 2)
auto First ()
 Executes a SELECT query for the first record found and returns it with only the specified fields populated.
 
auto First (size_t n)
 Executes a SELECT query for the first n records found and returns them.
 
template<auto... ReferencedFields>
auto First (size_t n)
 Executes a SELECT query for the first n records with only the specified fields populated.
 
auto Range (size_t offset, size_t limit)
 Executes a SELECT query for a range of records and returns them.
 
template<auto... ReferencedFields>
auto Range (size_t offset, size_t limit)
 Executes a SELECT query for a range of records with only the specified fields populated.
 

Protected Member Functions

LIGHTWEIGHT_FORCE_INLINE SqlCoreDataMapperQueryBuilder (DataMapper &dm, std::string fields) noexcept
 Constructs a query builder with the given data mapper and field list.
 

Detailed Description

template<typename Record, typename Derived, DataMapperOptions QueryOptions = {}>
class Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >

Main API for mapping records to C++ from the database using high level C++ syntax.

Definition at line 46 of file QueryBuilders.hpp.

Constructor & Destructor Documentation

◆ SqlCoreDataMapperQueryBuilder()

template<typename Record , typename Derived , DataMapperOptions QueryOptions>
Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >::SqlCoreDataMapperQueryBuilder ( DataMapper dm,
std::string  fields 
)
inlineexplicitprotectednoexcept

Constructs a query builder with the given data mapper and field list.

Definition at line 1067 of file DataMapper.hpp.

Member Function Documentation

◆ Exist()

template<typename Record , typename Derived , DataMapperOptions QueryOptions = {}>
auto Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >::Exist ( )
inline

Executes a SELECT 1 ... query and returns true if a record exists We do not provide db specific syntax to check this but reuse the First() implementation

Definition at line 80 of file QueryBuilders.hpp.

◆ Count()

template<typename Record , typename Derived , DataMapperOptions QueryOptions = {}>
auto Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >::Count ( )
inline

Executes a SELECT COUNT query and returns the number of records found.

Definition at line 86 of file QueryBuilders.hpp.

◆ All() [1/3]

template<typename Record , typename Derived , DataMapperOptions QueryOptions = {}>
auto Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >::All ( )
inline

Executes a SELECT query and returns all records found.

Definition at line 92 of file QueryBuilders.hpp.

◆ Delete()

template<typename Record , typename Derived , DataMapperOptions QueryOptions = {}>
auto Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >::Delete ( )
inline

Executes a DELETE query.

Definition at line 98 of file QueryBuilders.hpp.

◆ All() [2/3]

template<typename Record , typename Derived , DataMapperOptions QueryOptions = {}>
template<auto Field>
requires std::is_member_object_pointer_v<decltype(Field)>
auto Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >::All ( )
inline

Executes a SELECT query and returns all records found for the specified field.

Template Parameters
FieldThe field to select from the record, in the form of &Record::FieldName.
Returns
A vector of values of the type of the specified field.
auto dm = DataMapper {};
auto const ages = dm.Query<Person>()
.OrderBy(FieldNameOf<&Person::age>, SqlResultOrdering::ASCENDING)
.All<&Person::age>();
Main API for mapping records to and from the database using high level C++ syntax.
std::vector< Record > Query(SqlSelectQueryBuilder::ComposedQuery const &selectQuery, InputParameters &&... inputParameters)

Definition at line 121 of file QueryBuilders.hpp.

◆ All() [3/3]

template<typename Record , typename Derived , DataMapperOptions QueryOptions = {}>
template<auto... ReferencedFields>
requires (sizeof...(ReferencedFields) >= 2)
auto Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >::All ( )
inline

Executes a SELECT query and returns all records found for the specified field, only having the specified fields queried and populated.

Template Parameters
ReferencedFieldsThe fields to select from the record, in the form of &Record::FieldName.
Returns
A vector of records with the given fields populated.
auto dm = DataMapper {};
auto const ages = dm.Query<Person>()
.OrderBy(FieldNameOf<&Person::age>, SqlResultOrdering::ASCENDING)
.All<&Person::name, &Person::age>();

Definition at line 141 of file QueryBuilders.hpp.

◆ First() [1/5]

template<typename Record , typename Derived , DataMapperOptions QueryOptions = {}>
auto Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >::First ( )
inline

Executes a SELECT query for the first record found and returns it.

Definition at line 147 of file QueryBuilders.hpp.

◆ First() [2/5]

template<typename Record , typename Derived , DataMapperOptions QueryOptions = {}>
template<auto Field>
requires std::is_member_object_pointer_v<decltype(Field)>
auto Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >::First ( )
inline

Executes the query to get a single scalar value from the first record found.

Template Parameters
FieldThe field to select from the record, in the form of &Record::FieldName.
Returns
an optional value of the type of the field, or an empty optional if no record was found.

Definition at line 163 of file QueryBuilders.hpp.

◆ First() [3/5]

template<typename Record , typename Derived , DataMapperOptions QueryOptions = {}>
template<auto... ReferencedFields>
requires (sizeof...(ReferencedFields) >= 2)
auto Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >::First ( )
inline

Executes a SELECT query for the first record found and returns it with only the specified fields populated.

Template Parameters
ReferencedFieldsThe fields to select from the record, in the form of &Record::FieldName.
Returns
an optional record with only the specified fields populated, or an empty optional if no record was found.

Definition at line 175 of file QueryBuilders.hpp.

◆ First() [4/5]

template<typename Record , typename Derived , DataMapperOptions QueryOptions = {}>
auto Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >::First ( size_t  n)
inline

Executes a SELECT query for the first n records found and returns them.

Definition at line 181 of file QueryBuilders.hpp.

◆ First() [5/5]

template<typename Record , typename Derived , DataMapperOptions QueryOptions = {}>
template<auto... ReferencedFields>
auto Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >::First ( size_t  n)
inline

Executes a SELECT query for the first n records with only the specified fields populated.

Definition at line 188 of file QueryBuilders.hpp.

◆ Range() [1/2]

template<typename Record , typename Derived , DataMapperOptions QueryOptions = {}>
auto Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >::Range ( size_t  offset,
size_t  limit 
)
inline

Executes a SELECT query for a range of records and returns them.

Definition at line 194 of file QueryBuilders.hpp.

◆ Range() [2/2]

template<typename Record , typename Derived , DataMapperOptions QueryOptions = {}>
template<auto... ReferencedFields>
auto Lightweight::SqlCoreDataMapperQueryBuilder< Record, Derived, QueryOptions >::Range ( size_t  offset,
size_t  limit 
)
inline

Executes a SELECT query for a range of records with only the specified fields populated.

Definition at line 201 of file QueryBuilders.hpp.


The documentation for this class was generated from the following files: