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
@@ -189,10 +189,11 @@ public:
}
static Traps FindOne(
Database& db,
int traps_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
@@ -237,10 +238,11 @@ public:
}
static int DeleteOne(
Database& db,
int traps_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
@@ -253,6 +255,7 @@ public:
}
static int UpdateOne(
Database& db,
Traps traps_entry
)
{
@@ -285,7 +288,7 @@ public:
update_values.push_back(columns[23] + " = '" + EscapeString(traps_entry.content_flags) + "'");
update_values.push_back(columns[24] + " = '" + EscapeString(traps_entry.content_flags_disabled) + "'");
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
@@ -299,6 +302,7 @@ public:
}
static Traps InsertOne(
Database& db,
Traps traps_entry
)
{
@@ -348,6 +352,7 @@ public:
}
static int InsertMany(
Database& db,
std::vector<Traps> traps_entries
)
{
@@ -386,7 +391,7 @@ public:
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
@@ -397,11 +402,11 @@ public:
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Traps> All()
static std::vector<Traps> All(Database& db)
{
std::vector<Traps> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
@@ -445,11 +450,11 @@ public:
return all_entries;
}
static std::vector<Traps> GetWhere(std::string where_filter)
static std::vector<Traps> GetWhere(Database& db, std::string where_filter)
{
std::vector<Traps> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
@@ -494,9 +499,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(),
@@ -507,9 +512,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()