|
- #pragma once
-
- #include "data_context.h"
- #include "../impl/filter.h"
-
- namespace cpphibernate {
- namespace mariadb {
-
- /**
- * @brief Context that is used for create or update operations.
- */
- struct create_update_context
- : public data_context
- {
- const filter_t * filter; //!< Filter that is used for update operation.
- //!< Also indicated if this is an update or create operation.
- const table_t * derived_table; //!< Derived table if the current context is executed in a base table.
- const field_t * owner_field; //!< Field the current dataset is owned by (for foreign fields)
- std::string owner_key; //!< Key of the dataset the current dataset is owned by.
- ssize_t index; //!< Index of the current dataset in the container.
-
- /**
- * @brief Constructor. Creates a create context (no filters are passed).
- *
- * @param[in] p_schema Mariadb driver schema to use for the operation.
- * @param[in] p_connection Mariadb connection to execute queries with.
- * @param[in] p_dataset Dataset to store in the context.
- */
- template<typename T_dataset>
- inline create_update_context(
- const schema_t& p_schema,
- ::cppmariadb::connection& p_connection,
- T_dataset& p_dataset);
-
- /**
- * @brief Constructor. Create an update context.
- *
- * @param[in] p_schema Mariadb driver schema to use for the operation.
- * @param[in] p_connection Mariadb connection to execute queries with.
- * @param[in] p_dataset Dataset to store in the context.
- * @param[in] p_filter Filters to use for the update operation.
- */
- template<typename T_dataset>
- inline create_update_context(
- const schema_t& p_schema,
- ::cppmariadb::connection& p_connection,
- T_dataset& p_dataset,
- const filter_t& p_filter);
-
- /**
- * @brief Create a create context from the current context.
- */
- inline decltype(auto) make_create_context() const;
-
- /**
- * @brief Create an update context from the current context.
- */
- inline decltype(auto) make_update_context(const filter_t& p_filter) const;
-
- /**
- * @brief Returns true if this is an create context, false otherwise.
- */
- inline bool is_create() const;
-
- /**
- * @brief Returns true if this is an update context, false otherwise.
- */
- inline bool is_update() const;
- };
-
- } }
|