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
@@ -138,10 +138,11 @@ public:
}
static CharacterBind FindOne(
Database& db,
int character_bind_id
)
{
auto results = database.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
@@ -169,10 +170,11 @@ public:
}
static int DeleteOne(
Database& db,
int character_bind_id
)
{
auto results = database.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
@@ -185,6 +187,7 @@ public:
}
static int UpdateOne(
Database& db,
CharacterBind character_bind_entry
)
{
@@ -200,7 +203,7 @@ public:
update_values.push_back(columns[6] + " = " + std::to_string(character_bind_entry.z));
update_values.push_back(columns[7] + " = " + std::to_string(character_bind_entry.heading));
auto results = database.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
@@ -214,6 +217,7 @@ public:
}
static CharacterBind InsertOne(
Database& db,
CharacterBind character_bind_entry
)
{
@@ -246,6 +250,7 @@ public:
}
static int InsertMany(
Database& db,
std::vector<CharacterBind> character_bind_entries
)
{
@@ -267,7 +272,7 @@ public:
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
@@ -278,11 +283,11 @@ public:
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<CharacterBind> All()
static std::vector<CharacterBind> All(Database& db)
{
std::vector<CharacterBind> all_entries;
auto results = database.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
@@ -309,11 +314,11 @@ public:
return all_entries;
}
static std::vector<CharacterBind> GetWhere(std::string where_filter)
static std::vector<CharacterBind> GetWhere(Database& db, std::string where_filter)
{
std::vector<CharacterBind> all_entries;
auto results = database.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
@@ -341,9 +346,9 @@ public:
return all_entries;
}
static int DeleteWhere(std::string where_filter)
static int DeleteWhere(Database& db, std::string where_filter)
{
auto results = database.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
@@ -354,9 +359,9 @@ public:
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate()
static int Truncate(Database& db)
{
auto results = database.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()