Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Вопрос Что я не так делаю при изменении текста в колоне PostrgeSQL (supabase)

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
24 Дек 2025
Сообщения
15
Реакции
0
код

пук:
Expand Collapse Copy
#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

main.cpp:
Expand Collapse Copy
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;
}
в супе у меня 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);
 
на зло не хочу спунфидить твою ясную проблему, спроси нейронку и я боюсь что она почти с любого промпта с первого раза может тебе ответить
 
на зло не хочу спунфидить твою ясную проблему, спроси нейронку и я боюсь что она почти с любого промпта с первого раза может тебе ответить
так и не понял в чем трабл,но видимо с самой таблицей, потому что я ввел
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);
create policy "insert all"
on bd
for insert
with check (true);
insert into bd (name, value, bruh)
values ('bruh', 'initial', 'test')
on conflict (name) do nothing;

и заработало, мейби из-за инсерта
 
Назад
Сверху Снизу