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
@@ -825,10 +825,11 @@ public:
}
static SpellsNew FindOne(
Database& db,
int spells_new_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
@@ -1085,10 +1086,11 @@ public:
}
static int DeleteOne(
Database& db,
int spells_new_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
@@ -1101,6 +1103,7 @@ public:
}
static int UpdateOne(
Database& db,
SpellsNew spells_new_entry
)
{
@@ -1346,7 +1349,7 @@ public:
update_values.push_back(columns[235] + " = " + std::to_string(spells_new_entry.field235));
update_values.push_back(columns[236] + " = " + std::to_string(spells_new_entry.field236));
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
@@ -1360,6 +1363,7 @@ public:
}
static SpellsNew InsertOne(
Database& db,
SpellsNew spells_new_entry
)
{
@@ -1622,6 +1626,7 @@ public:
}
static int InsertMany(
Database& db,
std::vector<SpellsNew> spells_new_entries
)
{
@@ -1873,7 +1878,7 @@ public:
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
@@ -1884,11 +1889,11 @@ public:
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<SpellsNew> All()
static std::vector<SpellsNew> All(Database& db)
{
std::vector<SpellsNew> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
@@ -2144,11 +2149,11 @@ public:
return all_entries;
}
static std::vector<SpellsNew> GetWhere(std::string where_filter)
static std::vector<SpellsNew> GetWhere(Database& db, std::string where_filter)
{
std::vector<SpellsNew> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
@@ -2405,9 +2410,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(),
@@ -2418,9 +2423,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()