Начинающий
Начинающий
- Статус
- Оффлайн
- Регистрация
- 24 Дек 2025
- Сообщения
- 15
- Реакции
- 0
код
в main
в супе у меня 3 колонны - name, value, bruh, самые дефолтные, типо так
create table bd(
name text primary key,
value text,
bruh text
);
alter table bd enable row level security;
create policy "read all"
on bd for select
using (true);
create policy "write all"
on bd for update
using (true);
пук:
#include "../depens.h"
static size_t write_cb(void* contents, size_t size, size_t nmemb, void* userp) {
((string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
// method: false - GET; true - PATCH
string request(const string& url, const bool method, const string& body = "") {
CURL* curl = curl_easy_init();
string response;
struct curl_slist* headers = nullptr;
headers = curl_slist_append(headers, xorstr_("Content-Type: application/json"));
headers = curl_slist_append(headers, xorstr_("apikey: ы"));
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
if (method) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, xorstr_("PATCH"));
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
}
curl_easy_perform(curl);
curl_easy_cleanup(curl);
return response;
}
class Auth {
public:
string read(const string& nameLine) {
string url =
"https://ы.supabase.co/rest/v1/bd"
"?select=" + nameLine;
return request(url, false);
}
void write(const string& nameLine, const string& newLine) {
string url =
"https://ы.supabase.co/rest/v1/bd"
"?select=" + nameLine;
string body =
"{ \"value\": \"" + newLine + "\" }";
request(url, true, body);
}
};
main.cpp:
int main() {
Auth* auth = new Auth();
std::string result = auth->read("bruh");
std::cout << result << std::endl;
auth->write("bruh", "venom");
result = auth->read("bruh");
std::cout << result << std::endl;
}
create table bd(
name text primary key,
value text,
bruh text
);
alter table bd enable row level security;
create policy "read all"
on bd for select
using (true);
create policy "write all"
on bd for update
using (true);