4#include <TCriteriaMongoConverter>
39 bool findIn(
int column,
const QVariantList &values);
63 TMongoQuery(T().collectionName()), sortColumn(), sortOrder(
Tf::AscendingOrder)
93 sortColumn = TCriteriaMongoConverter<T>::propertyName(column);
102 if (!column.isEmpty()) {
104 if (obj.propertyNames().contains(column, Qt::CaseSensitive)) {
108 Tf::warn(
"Unable to set sort order : '{}' field not found in '{}' collection",
109 qUtf8Printable(column), qUtf8Printable(obj.collectionName()));
134 setSortOrder(column, order);
142 setSortOrder(column, order);
152 if (!doc.isEmpty()) {
165 if (!doc.isEmpty()) {
177 if (!doc.isEmpty()) {
188 if (!sortColumn.isEmpty()) {
192 return TMongoQuery::find(TCriteriaMongoConverter<T>(criteria).toVariantMap(), order);
222 if (!doc.isEmpty()) {
239 return findCount(
TCriteria(column, value));
276 QString s = TCriteriaMongoConverter<T>::propertyName(column);
281 doc.insert(s, value);
291 for (
auto it = values.begin(); it != values.end(); ++it) {
292 QString s = TCriteriaMongoConverter<T>::propertyName(it.key());
294 doc.insert(s, it.value());
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
T findFirstBy(int column, const QVariant &value)
Definition tmongoodmapper.h:160
bool find(const TCriteria &cri=TCriteria())
Definition tmongoodmapper.h:185
bool findIn(int column, const QVariantList &values)
Definition tmongoodmapper.h:204
void setLimit(int limit)
Definition tmongoodmapper.h:76
virtual ~TMongoODMapper()
Destructor.
Definition tmongoodmapper.h:71
int removeAll(const TCriteria &cri=TCriteria())
Definition tmongoodmapper.h:303
TMongoODMapper()
Constructor.
Definition tmongoodmapper.h:62
T findOne(const TCriteria &cri=TCriteria())
Definition tmongoodmapper.h:148
int findCountBy(int column, const QVariant &value)
Definition tmongoodmapper.h:237
void setOffset(int offset)
Definition tmongoodmapper.h:83
int findCount(const TCriteria &cri=TCriteria())
Definition tmongoodmapper.h:230
bool next()
Definition tmongoodmapper.h:211
TMongoODMapper< T > & orderBy(int column, Tf::SortOrder order=Tf::AscendingOrder)
Definition tmongoodmapper.h:132
T findFirst(const TCriteria &cri=TCriteria())
Definition tmongoodmapper.h:34
T findByObjectId(const QString &id)
Definition tmongoodmapper.h:173
void setSortOrder(int column, Tf::SortOrder order=Tf::AscendingOrder)
Definition tmongoodmapper.h:90
bool findBy(int column, const QVariant &value)
Definition tmongoodmapper.h:197
int updateAll(const TCriteria &cri, int column, const QVariant &value)
Definition tmongoodmapper.h:274
T value() const
Definition tmongoodmapper.h:218
The TMongoQuery class provides a means of operating a MongoDB system.
Definition tmongoquery.h:10
int limit() const
Definition tmongoquery.h:54
int updateMulti(const QVariantMap &criteria, const QVariantMap &document)
Definition tmongoquery.h:30
bool next()
Retrieves the next document in the result set, if available, and positions on the retrieved document.
Definition tmongoquery.cpp:82
int count(const QVariantMap &criteria=QVariantMap())
Definition tmongoquery.cpp:273
void setLimit(int limit)
Sets the limit to limit, which is the limited number of documents for finding documents.
Definition tmongoquery.h:60
bool find(const QVariantMap &criteria=QVariantMap(), const QVariantMap &orderBy=QVariantMap(), const QStringList &fields=QStringList())
Finds documents by the criteria criteria in the collection and returns the number of the documents.
Definition tmongoquery.cpp:68
int offset() const
Definition tmongoquery.h:66
QVariantMap value() const
Returns the current document as a QVariantMap object.
Definition tmongoquery.cpp:93
void setOffset(int offset)
Sets the offset to offset, which is the number of documents to skip for finding documents.
Definition tmongoquery.h:72
QVariantMap findOne(const QVariantMap &criteria=QVariantMap(), const QStringList &fields=QStringList())
Finds documents by the criteria criteria in the collection and returns a retrieved document as a QVar...
Definition tmongoquery.cpp:106
int remove(const QVariantMap &criteria)
Removes documents that matches the criteria from the collection.
Definition tmongoquery.cpp:157
QVariantMap findById(const QString &id, const QStringList &fields=QStringList())
Definition tmongoquery.cpp:116
@ In
Definition tfnamespace.h:323
The Tf namespace contains miscellaneous identifiers used throughout the library of TreeFrog Framework...
Definition tdebug.h:10
SortOrder
Definition tfnamespace.h:133
@ AscendingOrder
Definition tfnamespace.h:134
void warn(const std::format_string< Args... > &fmt, Args &&... args)
Outputs the warning message to the log file, formatting args according to the format string fmt.
Definition tglobal.h:259
#define T_DISABLE_COPY(Class)
Definition tdeclexport.h:37
#define T_DISABLE_MOVE(Class)
Definition tdeclexport.h:41