QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
QxMongoDB_Helper.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** https://www.qxorm.com/
4** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
5**
6** This file is part of the QxOrm library
7**
8** This software is provided 'as-is', without any express or implied
9** warranty. In no event will the authors be held liable for any
10** damages arising from the use of this software
11**
12** Commercial Usage
13** Licensees holding valid commercial QxOrm licenses may use this file in
14** accordance with the commercial license agreement provided with the
15** Software or, alternatively, in accordance with the terms contained in
16** a written agreement between you and Lionel Marty
17**
18** GNU General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU
20** General Public License version 3.0 as published by the Free Software
21** Foundation and appearing in the file 'license.gpl3.txt' included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU General Public License version 3.0 requirements will be
24** met : http://www.gnu.org/copyleft/gpl.html
25**
26** If you are unsure which license is appropriate for your use, or
27** if you have questions regarding the use of this file, please contact :
28** contact@qxorm.com
29**
30****************************************************************************/
31
32#ifdef _QX_ENABLE_MONGODB
33#ifndef _QX_DAO_MONGODB_HELPER_H_
34#define _QX_DAO_MONGODB_HELPER_H_
35
36#ifdef _MSC_VER
37#pragma once
38#endif
39
47#include <QtSql/qsqlerror.h>
48
50
51namespace qx {
52
53class IxClass;
54class QxSqlQuery;
55
56} // namespace qx
57
58namespace qx {
59namespace dao {
60namespace detail {
61
62class IxDao_Helper;
63
64} // namespace detail
65} // namespace dao
66} // namespace qx
67
68namespace qx {
69namespace dao {
70namespace mongodb {
71
72struct QxMongoDB_Fetcher;
73
78class QX_DLL_EXPORT QxMongoDB_Helper : public QxSingleton<QxMongoDB_Helper>
79{
80
81 friend class QxSingleton<QxMongoDB_Helper>;
82
83public:
84
85 enum opts { opts_collection_insert_one, opts_collection_insert_many, opts_collection_update_one, opts_collection_update_many,
86 opts_collection_delete_one, opts_collection_delete_many, opts_collection_find, opts_collection_command, opts_collection_count,
87 opts_collection_create_bulk_operation, opts_bulk_operation_update_one, opts_bulk_operation_remove_one, opts_collection_aggregate };
88
89private:
90
91 struct QxMongoDB_HelperImpl;
92 std::unique_ptr<QxMongoDB_HelperImpl> m_pImpl;
93
94 QxMongoDB_Helper();
95 virtual ~QxMongoDB_Helper();
96
97public:
98
99 static QSqlError insertOne(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QString & json, QString & insertedId);
100 static QSqlError insertMany(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QStringList & json, QStringList & insertedId);
101 static QSqlError updateOne(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QString & json, const qx::QxSqlQuery * query = NULL);
102 static QSqlError updateMany(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QStringList & json, const qx::QxSqlQuery * query = NULL);
103 static QSqlError deleteOne(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QString & json, const qx::QxSqlQuery * query = NULL);
104 static QSqlError deleteMany(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QStringList & json, const qx::QxSqlQuery * query = NULL);
105 static QSqlError findOne(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, QString & json, const qx::QxSqlQuery * query = NULL);
106 static QSqlError findMany(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, QStringList & json, const qx::QxSqlQuery * query = NULL, QxMongoDB_Fetcher * pFetcher = NULL);
107 static QSqlError aggregate(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, QStringList & json, const qx::QxSqlQuery * query = NULL, const QString & lookup = QString(), QxMongoDB_Fetcher * pFetcher = NULL);
108 static QSqlError count(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, long & cnt, const qx::QxSqlQuery * query = NULL);
109 static QSqlError executeCommand(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, qx::QxSqlQuery * query);
110
111 static QSqlError autoCreateIndexes(bool log = true);
112 static bool setOptions(opts e, const QString & optsAsJson);
113 static void setLogDatabaseReply(bool b);
114 static void setLogDatabaseInfo(bool b);
115 static void clearPoolConnection();
116
117};
118
123struct QX_DLL_EXPORT QxMongoDB_Fetcher
124{
125
126 QxMongoDB_Fetcher();
127 virtual ~QxMongoDB_Fetcher();
128
129 virtual void fetch(const QString & json) = 0;
130
131};
132
133} // namespace mongodb
134} // namespace dao
135} // namespace qx
136
137QX_DLL_EXPORT_QX_SINGLETON_HPP(qx::dao::mongodb::QxMongoDB_Helper)
138
139#endif // _QX_DAO_MONGODB_HELPER_H_
140#endif // _QX_ENABLE_MONGODB
#define QX_DLL_EXPORT
Definition QxMacro.h:182
#define QX_DLL_EXPORT_QX_SINGLETON_HPP(x)
Definition QxMacro.h:190
Concrete class to define a thread-safe singleton of QxOrm library.
qx::IxClass : common interface for all classes registered into QxOrm context
Definition IxClass.h:69
qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library,...
Definition QxSqlQuery.h:245
qx::dao::detail::IxDao_Helper : helper class to communicate with database
long count()
Return the number of objects in the cache.
Definition QxCache.h:134
Root namespace for all QxOrm library features.