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
@@ -129,10 +129,11 @@ public:
}
static NpcEmotes FindOne(
Database& db,
int npc_emotes_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
@@ -157,10 +158,11 @@ public:
}
static int DeleteOne(
Database& db,
int npc_emotes_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
@@ -173,6 +175,7 @@ public:
}
static int UpdateOne(
Database& db,
NpcEmotes npc_emotes_entry
)
{
@@ -185,7 +188,7 @@ public:
update_values.push_back(columns[3] + " = " + std::to_string(npc_emotes_entry.type));
update_values.push_back(columns[4] + " = '" + EscapeString(npc_emotes_entry.text) + "'");
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
@@ -199,6 +202,7 @@ public:
}
static NpcEmotes InsertOne(
Database& db,
NpcEmotes npc_emotes_entry
)
{
@@ -228,6 +232,7 @@ public:
}
static int InsertMany(
Database& db,
std::vector<NpcEmotes> npc_emotes_entries
)
{
@@ -246,7 +251,7 @@ public:
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
@@ -257,11 +262,11 @@ public:
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<NpcEmotes> All()
static std::vector<NpcEmotes> All(Database& db)
{
std::vector<NpcEmotes> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
@@ -285,11 +290,11 @@ public:
return all_entries;
}
static std::vector<NpcEmotes> GetWhere(std::string where_filter)
static std::vector<NpcEmotes> GetWhere(Database& db, std::string where_filter)
{
std::vector<NpcEmotes> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
@@ -314,9 +319,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(),
@@ -327,9 +332,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()