SQT
A C++ ORM framework for SQLite
Loading...
Searching...
No Matches

◆ MakeDeleter()

template<EntityValueType ENTITY>
constexpr auto sqt::DataContext< ENTITY >::MakeDeleter ( )
staticconstexprnoexcept

Creates a deleter for deleting rows from the database table.

Returns
A new deleter instance.

The returned deleter corresponds to a DELETE SQL statement without any conditions, so it will deleter all rows from the table. To control which rows to delete, use the Where() method of the deleter to create a new deleter with conditions. The following code demonstrates how to use the deleter:

// The entity type, assuming its table type has been defined and registered, and its
// columns' names are defined as the same as the entity's field names.
struct MyEntity {
int id{};
std::string name;
};
// Create the deleter with a condition.
constexpr auto deleter = sqt::DataContext<MyEntity>::MakeDeleter().Where(
);
// Create a data context, assuming the shared_db is an opened database instance.
sqt::DataContext<MyEntity> data_context{ shared_db };
// Prepare the deleter to create a corresponding executor.
auto executor = data_context.Prepare(deleter);
// Execute the statement.
executor.Execute();
static constexpr auto MakeDeleter() noexcept
Creates a deleter for deleting rows from the database table.
Definition data_context.h:465
Executor< QUERIER > Prepare(const QUERIER &querier)
Creates an executor for executing the specified querier.
Definition data_context.h:639
Provides a set of operations for performing CRUD (Create, Read, Update, Delete) operations on a datab...
Definition data_context.h:96
constexpr const auto & Table
A helper template to retrieve the singleton instance of the table type associated with an entity type...
Definition table_mapping.h:64

For easier-to-use methods, use the following methods from the easy style interface:

  • Delete() for deleting a row by the specified primary key value.
  • DeleteAll() for deleting all rows in the table.
See also
sqt::DataContext<>::Delete()
sqt::DataContext<>::DeleteAll()