| QxOrm 1.4.8 C++ Object Relational Mapping library

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

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
    00072 struct QxMongoDB_Fetcher;
    00073
    00078 class QX_DLL_EXPORT QxMongoDB_Helper : public QxSingleton<QxMongoDB_Helper>
    00079 {
    00080
    00081    friend class QxSingleton<QxMongoDB_Helper>;
    00082
    00083 public:
    00084
    00085    enum opts { opts_collection_insert_one, opts_collection_insert_many, opts_collection_update_one, opts_collection_update_many,
    00086                opts_collection_delete_one, opts_collection_delete_many, opts_collection_find, opts_collection_command, opts_collection_count,
    00087                opts_collection_create_bulk_operation, opts_bulk_operation_update_one, opts_bulk_operation_remove_one, opts_collection_aggregate };
    00088
    00089 private:
    00090
    00091    struct QxMongoDB_HelperImpl;
    00092    std::unique_ptr<QxMongoDB_HelperImpl> m_pImpl;
    00093
    00094    QxMongoDB_Helper();
    00095    virtual ~QxMongoDB_Helper();
    00096
    00097 public:
    00098
    00099    static QSqlError insertOne(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QString & json, QString & insertedId);
    00100    static QSqlError insertMany(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QStringList & json, QStringList & insertedId);
    00101    static QSqlError updateOne(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QString & json, const qx::QxSqlQuery * query = NULL);
    00102    static QSqlError updateMany(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QStringList & json, const qx::QxSqlQuery * query = NULL);
    00103    static QSqlError deleteOne(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QString & json, const qx::QxSqlQuery * query = NULL);
    00104    static QSqlError deleteMany(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, const QStringList & json, const qx::QxSqlQuery * query = NULL);
    00105    static QSqlError findOne(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, QString & json, const qx::QxSqlQuery * query = NULL);
    00106    static QSqlError findMany(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, QStringList & json, const qx::QxSqlQuery * query = NULL, QxMongoDB_Fetcher * pFetcher = NULL);
    00107    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);
    00108    static QSqlError count(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, long & cnt, const qx::QxSqlQuery * query = NULL);
    00109    static QSqlError executeCommand(qx::dao::detail::IxDao_Helper * pDaoHelper, qx::IxClass * pClass, qx::QxSqlQuery * query);
    00110
    00111    static QSqlError autoCreateIndexes(bool log = true);
    00112    static bool setOptions(opts e, const QString & optsAsJson);
    00113    static void setLogDatabaseReply(bool b);
    00114    static void setLogDatabaseInfo(bool b);
    00115    static void clearPoolConnection();
    00116
    00117 };
    00118
    00123 struct QX_DLL_EXPORT QxMongoDB_Fetcher
    00124 {
    00125
    00126    QxMongoDB_Fetcher();
    00127    virtual ~QxMongoDB_Fetcher();
    00128
    00129    virtual void fetch(const QString & json) = 0;
    00130
    00131 };
    00132
    00133 } // namespace mongodb
    00134 } // namespace dao
    00135 } // namespace qx
    00136
    00137 QX_DLL_EXPORT_QX_SINGLETON_HPP(qx::dao::mongodb::QxMongoDB_Helper)
    00138
    00139 #endif // _QX_DAO_MONGODB_HELPER_H_
    00140 #endif // _QX_ENABLE_MONGODB