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
@@ -126,10 +126,11 @@ public:
}
static Spawnentry FindOne(
Database& db,
int spawnentry_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
@@ -153,10 +154,11 @@ public:
}
static int DeleteOne(
Database& db,
int spawnentry_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
@@ -169,6 +171,7 @@ public:
}
static int UpdateOne(
Database& db,
Spawnentry spawnentry_entry
)
{
@@ -181,7 +184,7 @@ public:
update_values.push_back(columns[2] + " = " + std::to_string(spawnentry_entry.chance));
update_values.push_back(columns[3] + " = " + std::to_string(spawnentry_entry.condition_value_filter));
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
@@ -195,6 +198,7 @@ public:
}
static Spawnentry InsertOne(
Database& db,
Spawnentry spawnentry_entry
)
{
@@ -224,6 +228,7 @@ public:
}
static int InsertMany(
Database& db,
std::vector<Spawnentry> spawnentry_entries
)
{
@@ -242,7 +247,7 @@ public:
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
@@ -253,11 +258,11 @@ public:
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Spawnentry> All()
static std::vector<Spawnentry> All(Database& db)
{
std::vector<Spawnentry> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
@@ -280,11 +285,11 @@ public:
return all_entries;
}
static std::vector<Spawnentry> GetWhere(std::string where_filter)
static std::vector<Spawnentry> GetWhere(Database& db, std::string where_filter)
{
std::vector<Spawnentry> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
@@ -308,9 +313,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(),
@@ -321,9 +326,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()