QxOrm  1.4.5
C++ Object Relational Mapping library
QxMongoDB_Helper.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** https://www.qxorm.com/
00004 ** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
00005 **
00006 ** This file is part of the QxOrm library
00007 **
00008 ** This software is provided 'as-is', without any express or implied
00009 ** warranty. In no event will the authors be held liable for any
00010 ** damages arising from the use of this software
00011 **
00012 ** Commercial Usage
00013 ** Licensees holding valid commercial QxOrm licenses may use this file in
00014 ** accordance with the commercial license agreement provided with the
00015 ** Software or, alternatively, in accordance with the terms contained in
00016 ** a written agreement between you and Lionel Marty
00017 **
00018 ** GNU General Public License Usage
00019 ** Alternatively, this file may be used under the terms of the GNU
00020 ** General Public License version 3.0 as published by the Free Software
00021 ** Foundation and appearing in the file 'license.gpl3.txt' included in the
00022 ** packaging of this file. Please review the following information to
00023 ** ensure the GNU General Public License version 3.0 requirements will be
00024 ** met : http://www.gnu.org/copyleft/gpl.html
00025 **
00026 ** If you are unsure which license is appropriate for your use, or
00027 ** if you have questions regarding the use of this file, please contact :
00028 ** contact@qxorm.com
00029 **
00030 ****************************************************************************/
00031 
00032 #ifdef _QX_ENABLE_MONGODB
00033 #ifndef _QX_DAO_MONGODB_HELPER_H_
00034 #define _QX_DAO_MONGODB_HELPER_H_
00035 
00036 #ifdef _MSC_VER
00037 #pragma once
00038 #endif
00039 
00047 #include <QtSql/qsqlerror.h>
00048 
00049 #include <QxSingleton/QxSingleton.h>
00050 
00051 namespace qx {
00052 
00053 class IxClass;
00054 class QxSqlQuery;
00055 
00056 } // namespace qx
00057 
00058 namespace qx {
00059 namespace dao {
00060 namespace detail {
00061 
00062 class IxDao_Helper;
00063 
00064 } // namespace detail
00065 } // namespace dao
00066 } // namespace qx
00067 
00068 namespace qx {
00069 namespace dao {
00070 namespace mongodb {
00071 
00076 class QX_DLL_EXPORT QxMongoDB_Helper : public QxSingleton<QxMongoDB_Helper>
00077 {
00078 
00079    friend class QxSingleton<QxMongoDB_Helper>;
00080 
00081 public:
00082 
00083    enum opts { opts_collection_insert_one, opts_collection_insert_many, opts_collection_update_one, opts_collection_update_many, 
00084                opts_collection_delete_one, opts_collection_delete_many, opts_collection_find, opts_collection_command, opts_collection_count, 
00085                opts_collection_create_bulk_operation, opts_bulk_operation_update_one, opts_bulk_operation_remove_one, opts_collection_aggregate };
00086 
00087 private:
00088 
00089    struct QxMongoDB_HelperImpl;
00090    std::unique_ptr<QxMongoDB_HelperImpl> m_pImpl; 
00091 
00092    QxMongoDB_Helper();
00093    virtual ~QxMongoDB_Helper();
00094 
00095 public:
00096 
00097    static QSqlError insertOne(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QString & json, QString & insertedId);
00098    static QSqlError insertMany(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QStringList & json, QStringList & insertedId);
00099    static QSqlError updateOne(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QString & json, const qx::QxSqlQuery * query = NULL);
00100    static QSqlError updateMany(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QStringList & json, const qx::QxSqlQuery * query = NULL);
00101    static QSqlError deleteOne(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QString & json, const qx::QxSqlQuery * query = NULL);
00102    static QSqlError deleteMany(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QStringList & json, const qx::QxSqlQuery * query = NULL);
00103    static QSqlError findOne(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, QString & json, const qx::QxSqlQuery * query = NULL);
00104    static QSqlError findMany(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, QStringList & json, const qx::QxSqlQuery * query = NULL);
00105    static QSqlError aggregate(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, QStringList & json, const qx::QxSqlQuery * query = NULL, const QString & lookup = QString());
00106    static QSqlError count(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, long & cnt, const qx::QxSqlQuery * query = NULL);
00107    static QSqlError executeCommand(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, qx::QxSqlQuery * query);
00108 
00109    static QSqlError autoCreateIndexes(bool log = true);
00110    static bool setOptions(opts e, const QString & optsAsJson);
00111    static void setLogDatabaseReply(bool b);
00112    static void clearPoolConnection();
00113 
00114 };
00115 
00116 } // namespace mongodb
00117 } // namespace dao
00118 } // namespace qx
00119 
00120 QX_DLL_EXPORT_QX_SINGLETON_HPP(qx::dao::mongodb::QxMongoDB_Helper)
00121 
00122 #endif // _QX_DAO_MONGODB_HELPER_H_
00123 #endif // _QX_ENABLE_MONGODB