From 79be89ad0491bfdd110b2c612e21a0f28c29fa87 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 2 Jul 2025 03:31:54 +0500 Subject: feat: MARIADB SUPPORT!!!! --- bot/src/schemas/user.hpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'bot/src/schemas/user.hpp') diff --git a/bot/src/schemas/user.hpp b/bot/src/schemas/user.hpp index e9d7e0f..ee9bd10 100644 --- a/bot/src/schemas/user.hpp +++ b/bot/src/schemas/user.hpp @@ -2,26 +2,26 @@ #include #include -#include #include #include #include "../utils/chrono.hpp" +#include "database.hpp" namespace bot::schemas { class User { public: - User(const pqxx::row &row) { - this->id = row[0].as(); - this->alias_id = row[1].as(); - this->alias_name = row[2].as(); + User(const db::DatabaseRow &row) { + this->id = std::stoi(row.at("id")); + this->alias_id = std::stoi(row.at("alias_id")); + this->alias_name = row.at("alias_name"); this->joined_at = - utils::chrono::string_to_time_point(row[3].as()); + utils::chrono::string_to_time_point(row.at("joined_at")); - if (!row[4].is_null()) { + if (!row.at("opted_out_at").empty()) { this->opted_out_at = - utils::chrono::string_to_time_point(row[4].as()); + utils::chrono::string_to_time_point(row.at("opted_out_at")); } } @@ -54,11 +54,11 @@ namespace bot::schemas { class UserRights { public: - UserRights(const pqxx::row &row) { - this->id = row[0].as(); - this->user_id = row[1].as(); - this->channel_id = row[2].as(); - this->level = static_cast(row[3].as()); + UserRights(const db::DatabaseRow &row) { + this->id = std::stoi(row.at("id")); + this->user_id = std::stoi(row.at("user_id")); + this->channel_id = std::stoi(row.at("channel_id")); + this->level = static_cast(std::stoi(row.at("level"))); } ~UserRights() = default; -- cgit v1.2.3