4#include <TCriteriaConverter>
5#include <TMongoODMapper>
7#include <TSqlORMapperIterator>
10template <
class T,
class S>
14 if (!sortColumns.isEmpty()) {
15 for (
auto &p : sortColumns) {
16 if (!p.first.isEmpty()) {
28 int count = mapper.
find(cri);
31 for (
auto &o : mapper) {
38template <
class T,
class S>
41 QList<QPair<QString, Tf::SortOrder>> sorts;
43 for (
auto &p : sortColumns) {
44 QString columnName = TCriteriaConverter<S>::getPropertyName(p.first,
nullptr);
45 if (!columnName.isEmpty()) {
46 sorts << qMakePair(columnName, p.second);
49 return tfGetModelListByCriteria<T, S>(cri, sorts, limit, offset);
52template <
class T,
class S>
55 QList<QPair<int, Tf::SortOrder>> sortColumns = {qMakePair(sortColumn, order)};
56 return tfGetModelListByCriteria<T, S>(cri, sortColumns, limit, offset);
59template <
class T,
class S>
62 QList<QPair<QString, Tf::SortOrder>> sortColumns = {qMakePair(sortColumn, order)};
63 return tfGetModelListByCriteria<T, S>(cri, sortColumns, limit, offset);
66template <
class T,
class S>
70 return tfGetModelListByCriteria<T, S>(cri, sortColumns, limit, offset);
74template <
class T,
class S>
79 if (sortColumn >= 0) {
89 if (mapper.
find(cri)) {
90 while (mapper.
next()) {
91 list << T(mapper.
value());
98template <
class T,
class S>
101 return tfGetModelListByMongoCriteria<T, S>(cri, -1,
Tf::AscendingOrder, limit, offset);
109 for (
auto &it : list) {
110 array.append(it.toJsonObject(properties));
120 for (
auto &it : list) {
121 array.append(QCborValue(it.toCborMap()));
The TCriteria class represents a WHERE clause without SQL for the sake of database abstraction.
Definition tcriteria.h:6
The TMongoODMapper class is a template class that provides concise functionality to object-document m...
Definition tmongoodmapper.h:17
bool find(const TCriteria &cri=TCriteria())
Definition tmongoodmapper.h:185
void setLimit(int limit)
Definition tmongoodmapper.h:76
void setOffset(int offset)
Definition tmongoodmapper.h:83
bool next()
Definition tmongoodmapper.h:211
void setSortOrder(int column, Tf::SortOrder order=Tf::AscendingOrder)
Definition tmongoodmapper.h:90
T value() const
Definition tmongoodmapper.h:218
The TSqlORMapper class is a template class that provides concise functionality to object-relational m...
Definition tsqlormapper.h:53
int find(const TCriteria &cri=TCriteria())
Retrieves with the criteria cri from the table and returns the number of the ORM objects.
Definition tsqlormapper.h:241
void setSortOrder(int column, Tf::SortOrder order=Tf::AscendingOrder)
Sets the sort order for column to order.
Definition tsqlormapper.h:364
void setOffset(int offset)
Sets the offset to offset, which is the number of rows to skip for execution of SELECT statement.
Definition tsqlormapper.h:355
void setLimit(int limit)
Sets the limit to limit, which is the limited number of rows for execution of SELECT statement.
Definition tsqlormapper.h:345
SortOrder
Definition tfnamespace.h:133
@ AscendingOrder
Definition tfnamespace.h:134
QCborArray tfConvertToCborArray(const QList< T > &list)
Definition tmodelutil.h:117
QJsonArray tfConvertToJsonArray(const QList< T > &list, const QStringList &properties=QStringList())
Definition tmodelutil.h:106
QList< T > tfGetModelListByCriteria(const TCriteria &cri, const QList< QPair< QString, Tf::SortOrder > > &sortColumns, int limit=0, int offset=0)
Definition tmodelutil.h:11
QList< T > tfGetModelListByMongoCriteria(const TCriteria &cri, int sortColumn, Tf::SortOrder order, int limit=0, int offset=0)
Definition tmodelutil.h:75