TreeFrogFramework  2.8
tmongoquery.h
Go to the documentation of this file.
1 #pragma once
2 #include <QStringList>
3 #include <QVariant>
4 #include <TGlobal>
5 #include <TKvsDatabase>
6 
7 class TMongoDriver;
8 
9 
11 public:
12  TMongoQuery(const QString &collection);
13  TMongoQuery(const TMongoQuery &other);
14  virtual ~TMongoQuery() { }
15 
16  int limit() const;
17  void setLimit(int limit);
18  int offset() const;
19  void setOffset(int offset);
20  bool find(const QVariantMap &criteria = QVariantMap(), const QVariantMap &orderBy = QVariantMap(), const QStringList &fields = QStringList());
21  bool next();
22  QVariantMap value() const;
23 
24  QVariantMap findOne(const QVariantMap &criteria = QVariantMap(), const QStringList &fields = QStringList());
25  QVariantMap findById(const QString &id, const QStringList &fields = QStringList());
26  bool insert(QVariantMap &document);
27  int update(const QVariantMap &criteria, const QVariantMap &document, bool upsert = false);
28  bool updateById(const QVariantMap &document);
29  int updateMany(const QVariantMap &criteria, const QVariantMap &document);
30  int updateMulti(const QVariantMap &criteria, const QVariantMap &document) { return updateMany(criteria, document); }
31  int remove(const QVariantMap &criteria);
32  bool removeById(const QVariantMap &document);
33  int count(const QVariantMap &criteria = QVariantMap());
34  QString lastErrorString() const;
35 
36  TMongoQuery &operator=(const TMongoQuery &other);
37 
38 private:
39  TMongoDriver *driver();
40  const TMongoDriver *driver() const;
41 
42 private:
43  TMongoQuery(Tf::KvsEngine engine, const QString &collection);
44 
45  TKvsDatabase _database;
46  QString _collection;
47  int _queryLimit {0};
48  int _queryOffset {0};
49 
50  friend class TCacheMongoStore;
51 };
52 
53 
54 inline int TMongoQuery::limit() const
55 {
56  return _queryLimit;
57 }
58 
59 
60 inline void TMongoQuery::setLimit(int limit)
61 {
62  _queryLimit = limit;
63 }
64 
65 
66 inline int TMongoQuery::offset() const
67 {
68  return _queryOffset;
69 }
70 
71 
72 inline void TMongoQuery::setOffset(int offset)
73 {
74  _queryOffset = offset;
75 }
76 
The TMongoQuery class provides a means of operating a MongoDB system.
Definition: tmongoquery.h:10
int limit() const
Definition: tmongoquery.h:54
virtual ~TMongoQuery()
Definition: tmongoquery.h:14
int updateMulti(const QVariantMap &criteria, const QVariantMap &document)
Definition: tmongoquery.h:30
void setLimit(int limit)
Sets the limit to limit, which is the limited number of documents for finding documents.
Definition: tmongoquery.h:60
int offset() const
Definition: tmongoquery.h:66
void setOffset(int offset)
Sets the offset to offset, which is the number of documents to skip for finding documents.
Definition: tmongoquery.h:72
KvsEngine
Definition: tfnamespace.h:239
QString lastErrorString()
Definition: tcachesqlitestore.cpp:32
#define T_CORE_EXPORT
Definition: tdeclexport.h:28