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