Explicitly pass database pointers to repository methods

This commit is contained in:
Akkadius
2021-02-05 23:00:27 -06:00
parent 7fe0bbacd4
commit e8ab176d4a
167 changed files with 2738 additions and 1938 deletions
@@ -159,10 +159,11 @@ public:
}
static TradeskillRecipe FindOne(
Database& db,
int tradeskill_recipe_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
@@ -197,10 +198,11 @@ public:
}
static int DeleteOne(
Database& db,
int tradeskill_recipe_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
@@ -213,6 +215,7 @@ public:
}
static int UpdateOne(
Database& db,
TradeskillRecipe tradeskill_recipe_entry
)
{
@@ -235,7 +238,7 @@ public:
update_values.push_back(columns[13] + " = '" + EscapeString(tradeskill_recipe_entry.content_flags) + "'");
update_values.push_back(columns[14] + " = '" + EscapeString(tradeskill_recipe_entry.content_flags_disabled) + "'");
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
@@ -249,6 +252,7 @@ public:
}
static TradeskillRecipe InsertOne(
Database& db,
TradeskillRecipe tradeskill_recipe_entry
)
{
@@ -288,6 +292,7 @@ public:
}
static int InsertMany(
Database& db,
std::vector<TradeskillRecipe> tradeskill_recipe_entries
)
{
@@ -316,7 +321,7 @@ public:
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
@@ -327,11 +332,11 @@ public:
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<TradeskillRecipe> All()
static std::vector<TradeskillRecipe> All(Database& db)
{
std::vector<TradeskillRecipe> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
@@ -365,11 +370,11 @@ public:
return all_entries;
}
static std::vector<TradeskillRecipe> GetWhere(std::string where_filter)
static std::vector<TradeskillRecipe> GetWhere(Database& db, std::string where_filter)
{
std::vector<TradeskillRecipe> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
@@ -404,9 +409,9 @@ public:
return all_entries;
}
static int DeleteWhere(std::string where_filter)
static int DeleteWhere(Database& db, std::string where_filter)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
@@ -417,9 +422,9 @@ public:
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate()
static int Truncate(Database& db)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()