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
@@ -969,10 +969,11 @@ public:
}
static Items FindOne(
Database& db,
int items_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
@@ -1277,10 +1278,11 @@ public:
}
static int DeleteOne(
Database& db,
int items_id
)
{
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
@@ -1293,6 +1295,7 @@ public:
}
static int UpdateOne(
Database& db,
Items items_entry
)
{
@@ -1586,7 +1589,7 @@ public:
update_values.push_back(columns[283] + " = " + std::to_string(items_entry.UNK241));
update_values.push_back(columns[284] + " = " + std::to_string(items_entry.epicitem));
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
@@ -1600,6 +1603,7 @@ public:
}
static Items InsertOne(
Database& db,
Items items_entry
)
{
@@ -1910,6 +1914,7 @@ public:
}
static int InsertMany(
Database& db,
std::vector<Items> items_entries
)
{
@@ -2209,7 +2214,7 @@ public:
std::vector<std::string> insert_values;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
@@ -2220,11 +2225,11 @@ public:
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Items> All()
static std::vector<Items> All(Database& db)
{
std::vector<Items> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
@@ -2528,11 +2533,11 @@ public:
return all_entries;
}
static std::vector<Items> GetWhere(std::string where_filter)
static std::vector<Items> GetWhere(Database& db, std::string where_filter)
{
std::vector<Items> all_entries;
auto results = content_db.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
@@ -2837,9 +2842,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(),
@@ -2850,9 +2855,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()