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
@@ -171,10 +171,11 @@ public:
}
static Spawn2 FindOne(
Database& db,
int spawn2_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
@@ -213,10 +214,11 @@ public:
}
static int DeleteOne(
Database& db,
int spawn2_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
@@ -229,6 +231,7 @@ public:
}
static int UpdateOne(
Database& db,
Spawn2 spawn2_entry
)
{
@@ -255,7 +258,7 @@ public:
update_values.push_back(columns[17] + " = '" + EscapeString(spawn2_entry.content_flags) + "'");
update_values.push_back(columns[18] + " = '" + EscapeString(spawn2_entry.content_flags_disabled) + "'");
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
@@ -269,6 +272,7 @@ public:
}
static Spawn2 InsertOne(
Database& db,
Spawn2 spawn2_entry
)
{
@@ -312,6 +316,7 @@ public:
}
static int InsertMany(
Database& db,
std::vector<Spawn2> spawn2_entries
)
{
@@ -344,7 +349,7 @@ public:
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
@@ -355,11 +360,11 @@ public:
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Spawn2> All()
static std::vector<Spawn2> All(Database& db)
{
std::vector<Spawn2> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
@@ -397,11 +402,11 @@ public:
return all_entries;
}
static std::vector<Spawn2> GetWhere(std::string where_filter)
static std::vector<Spawn2> GetWhere(Database& db, std::string where_filter)
{
std::vector<Spawn2> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
@@ -440,9 +445,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(),
@@ -453,9 +458,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()