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
@@ -162,10 +162,11 @@ public:
}
static Inventory FindOne(
Database& db,
int inventory_id
)
{
auto results = database.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE id = {} LIMIT 1",
BaseSelect(),
@@ -201,10 +202,11 @@ public:
}
static int DeleteOne(
Database& db,
int inventory_id
)
{
auto results = database.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
@@ -217,6 +219,7 @@ public:
}
static int UpdateOne(
Database& db,
Inventory inventory_entry
)
{
@@ -241,7 +244,7 @@ public:
update_values.push_back(columns[14] + " = " + std::to_string(inventory_entry.ornamentidfile));
update_values.push_back(columns[15] + " = " + std::to_string(inventory_entry.ornament_hero_model));
auto results = database.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
@@ -255,6 +258,7 @@ public:
}
static Inventory InsertOne(
Database& db,
Inventory inventory_entry
)
{
@@ -296,6 +300,7 @@ public:
}
static int InsertMany(
Database& db,
std::vector<Inventory> inventory_entries
)
{
@@ -326,7 +331,7 @@ public:
std::vector<std::string> insert_values;
auto results = database.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
@@ -337,11 +342,11 @@ public:
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Inventory> All()
static std::vector<Inventory> All(Database& db)
{
std::vector<Inventory> all_entries;
auto results = database.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
@@ -376,11 +381,11 @@ public:
return all_entries;
}
static std::vector<Inventory> GetWhere(std::string where_filter)
static std::vector<Inventory> GetWhere(Database& db, std::string where_filter)
{
std::vector<Inventory> all_entries;
auto results = database.QueryDatabase(
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
@@ -416,9 +421,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(),
@@ -429,9 +434,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()