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
@@ -162,10 +162,11 @@ public:
}
static Tasks FindOne(
Database& db,
int tasks_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
@@ -201,10 +202,11 @@ public:
}
static int DeleteOne(
Database& db,
int tasks_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
@@ -217,6 +219,7 @@ public:
}
static int UpdateOne(
Database& db,
Tasks tasks_entry
)
{
@@ -241,7 +244,7 @@ public:
update_values.push_back(columns[14] + " = " + std::to_string(tasks_entry.faction_reward));
update_values.push_back(columns[15] + " = '" + EscapeString(tasks_entry.completion_emote) + "'");
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
@@ -255,6 +258,7 @@ public:
}
static Tasks InsertOne(
Database& db,
Tasks tasks_entry
)
{
@@ -296,6 +300,7 @@ public:
}
static int InsertMany(
Database& db,
std::vector<Tasks> tasks_entries
)
{
@@ -326,7 +331,7 @@ public:
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
@@ -337,11 +342,11 @@ public:
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Tasks> All()
static std::vector<Tasks> All(Database& db)
{
std::vector<Tasks> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
@@ -376,11 +381,11 @@ public:
return all_entries;
}
static std::vector<Tasks> GetWhere(std::string where_filter)
static std::vector<Tasks> GetWhere(Database& db, std::string where_filter)
{
std::vector<Tasks> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
@@ -416,9 +421,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(),
@@ -429,9 +434,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()