Lightweight 0.1.0
All Classes Functions Variables Typedefs Enumerations Modules Pages Concepts
Data Mapper

The data mapper is a high level API for mapping records to and from the database using high level C++ syntax. More...

Concepts

concept  FieldWithStorage
 
concept  DataMapperRecord
 Represents a record type that can be used with the DataMapper.
 

Classes

class  BelongsTo< TheReferencedField, ColumnNameOverrideString >
 Represents a one-to-one relationship. More...
 
class  SqlCoreDataMapperQueryBuilder< Record, Derived >
 
class  SqlSparseFieldQueryBuilder< Record, ReferencedFields >
 Represents a query builder that retrieves only the fields specified. More...
 
class  SqlAllFieldsQueryBuilder< Record >
 Represents a query builder that retrieves all fields of a record. More...
 
class  SqlQuerySingleBuilder< Record >
 Represents a query builder that retrieves only the first record found. More...
 
class  DataMapper
 Main API for mapping records to and from the database using high level C++ syntax. More...
 
class  SqlRequireLoadedError
 Represents an error when a record is required to be loaded but is not. More...
 
struct  Field< T, P1, P2 >
 Represents a single column in a table. More...
 
class  HasMany< OtherRecord >
 This HasMany<OtherRecord> represents a simple one-to-many relationship between two records. More...
 
class  HasManyThrough< ReferencedRecordT, ThroughRecordT >
 This API represents a many-to-many relationship between two records through a third record. More...
 
class  HasOneThrough< OtherTable, ThroughTable >
 Represents a one-to-one relationship through a join table. More...
 

Typedefs

template<size_t... Ints>
using SqlElements = std::integer_sequence< size_t, Ints... >
 Represents a sequence of indexes that can be used alongside Query() to retrieve only part of the record.
 

Functions

template<typename Record >
LIGHTWEIGHT_FORCE_INLINE RecordPrimaryKeyType< Record > GetPrimaryKeyField (Record const &record) noexcept
 

Variables

template<typename Record >
constexpr size_t RecordStorageFieldCount
 
template<typename T >
constexpr bool HasPrimaryKey = detail::CheckFieldProperty<[]<typename Field>() { return IsPrimaryKey<Field>; }, T>
 Tests if the given record type does contain a primary key.
 
template<typename T >
constexpr bool HasAutoIncrementPrimaryKey
 Tests if the given record type does contain an auto increment primary key.
 
template<std::size_t I, typename Record >
constexpr std::string_view FieldNameAt = detail::FieldNameAt<I, Record>()
 Returns the SQL field name of the given field index in the record.
 
template<typename Record >
constexpr std::string_view RecordTableName = detail::RecordTableNameImpl<Record>::Value
 Holds the SQL tabl ename for the given record type.
 

Detailed Description

The data mapper is a high level API for mapping records to and from the database using high level C++ syntax.

Typedef Documentation

◆ SqlElements

template<size_t... Ints>
using SqlElements = std::integer_sequence<size_t, Ints...>

Represents a sequence of indexes that can be used alongside Query() to retrieve only part of the record.

Definition at line 59 of file DataMapper.hpp.

Function Documentation

◆ GetPrimaryKeyField()

template<typename Record >
LIGHTWEIGHT_FORCE_INLINE RecordPrimaryKeyType< Record > GetPrimaryKeyField ( Record const &  record)
inlinenoexcept

Returns the first primary key field of the record.

Definition at line 417 of file DataMapper.hpp.

Referenced by Create().

Variable Documentation

◆ RecordStorageFieldCount

template<typename Record >
constexpr size_t RecordStorageFieldCount
constexpr
Initial value:
=
Reflection::FoldMembers<Record>(size_t { 0 }, []<size_t I, typename Field>(size_t const accum) constexpr {
if constexpr (FieldWithStorage<Field>)
return accum + 1;
else
return accum;
})
Represents a single column in a table.
Definition Field.hpp:71

Represents the number of fields with storage in a record.

Definition at line 44 of file DataMapper.hpp.

◆ HasPrimaryKey

template<typename T >
constexpr bool HasPrimaryKey = detail::CheckFieldProperty<[]<typename Field>() { return IsPrimaryKey<Field>; }, T>
constexpr

Tests if the given record type does contain a primary key.

Definition at line 78 of file DataMapper.hpp.

◆ HasAutoIncrementPrimaryKey

template<typename T >
constexpr bool HasAutoIncrementPrimaryKey
constexpr
Initial value:
=
detail::CheckFieldProperty<[]<typename Field>() { return IsAutoIncrementPrimaryKey<Field>; }, T>

Tests if the given record type does contain an auto increment primary key.

Definition at line 84 of file DataMapper.hpp.

◆ FieldNameAt

template<std::size_t I, typename Record >
constexpr std::string_view FieldNameAt = detail::FieldNameAt<I, Record>()
inlineconstexpr

Returns the SQL field name of the given field index in the record.

Definition at line 142 of file Utils.hpp.

◆ RecordTableName

template<typename Record >
constexpr std::string_view RecordTableName = detail::RecordTableNameImpl<Record>::Value
constexpr

Holds the SQL tabl ename for the given record type.

Definition at line 155 of file Utils.hpp.