LiteSQL
Public Member Functions | List of all members
litesql::DataSource< T > Class Template Reference

template class which holds SelectQuery for selecting objects of type T More...

#include <datasource.hpp>

Public Member Functions

 DataSource (const Database &db_, const Expr &e=Expr())
 
 DataSource (const Database &db_, const SelectQuery &sel_)
 
const DatabasegetDatabase () const
 returns database reference
 
SelectQuery idQuery () const
 returns SelectQuery which selects ID-numbers of objects
 
size_t count () const
 returns number of objects in result set
 
SelectQuery objectQuery () const
 returns SelectQuery which selects objects
 
Cursor< T > cursor () const
 returns cursor for query
 
one () const
 returns first object in result set. More...
 
std::vector< T > all () const
 returns all objects in result set.
 
DataSourceorderBy (FieldType f, bool asc=true)
 modifies SelectQuery to order result set More...
 
DataSourceorderByRelation (FieldType id, FieldType f, bool asc=true)
 modifies SelectQuery to order result set by external table More...
 

Detailed Description

template<class T>
class litesql::DataSource< T >

template class which holds SelectQuery for selecting objects of type T

Constructor & Destructor Documentation

◆ DataSource() [1/2]

template<class T >
litesql::DataSource< T >::DataSource ( const Database db_,
const Expr e = Expr() 
)
inline
Parameters
db_database reference
eselection filter

References litesql::selectObjectQuery().

◆ DataSource() [2/2]

template<class T >
litesql::DataSource< T >::DataSource ( const Database db_,
const SelectQuery sel_ 
)
inline
Parameters
db_database reference
sel_selection query

Member Function Documentation

◆ one()

template<class T >
T litesql::DataSource< T >::one ( ) const
inline

returns first object in result set.

throw exception if none found

Returns
object of type T

References litesql::DataSource< T >::cursor().

◆ orderBy()

template<class T >
DataSource& litesql::DataSource< T >::orderBy ( FieldType  f,
bool  asc = true 
)
inline

modifies SelectQuery to order result set

Parameters
ffield to order by
ascascending order
Returns
*this, methods can be chained

◆ orderByRelation()

template<class T >
DataSource& litesql::DataSource< T >::orderByRelation ( FieldType  id,
FieldType  f,
bool  asc = true 
)
inline

modifies SelectQuery to order result set by external table

Parameters
idforeign key field used to join table with query
ffield to order by
ascascending order
Returns
*this, methods can be chained

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

SourceForge.net Logo