Przejdź do treści
Intum
Aktualizacja: 1 min czytania

Bazy danych Noe — API

Autoryzacja: Authorization: Bearer TOKEN
Content-Type: application/json

Endpoints bazy

Metoda Ścieżka Opis
GET /noe/dbs.json Lista baz
GET /noe/dbs/:id.json Szczegóły bazy
POST /noe/dbs.json Utworzenie bazy
PATCH /noe/dbs/:id.json Aktualizacja bazy
DELETE /noe/dbs/:id.json Usunięcie bazy
GET /noe/dbs/:id/search.json Wyszukiwanie rekordów

Pola bazy

Pole Typ Wymagane Opis
name string tak Nazwa bazy
code string tak Kod unikalny (per konto)
schema jsonb tak Definicja struktury danych
public_methods jsonb nie Konfiguracja publicznych metod

Format schema

{
  "fields": {
    "title": { "type": "string", "required": true },
    "done": { "type": "integer" },
    "created": { "type": "datetime" }
  },
  "indexes": {
    "idx_str_1": "title",
    "idx_int_1": "done",
    "idx_time_1": "created"
  }
}

Typy pól: string, text, integer, number, boolean, datetime, date, time

Indeksy: idx_str_1-idx_str_3 (string), idx_int_1-idx_int_2 (bigint), idx_time_1-idx_time_2 (datetime)

POST — Utworzenie bazy

POST /noe/dbs.json

{
  "db": {
    "name": "Todo",
    "code": "todo",
    "schema": {
      "fields": {
        "title": { "type": "string", "required": true },
        "done": { "type": "integer" }
      },
      "indexes": {
        "idx_str_1": "title",
        "idx_int_1": "done"
      }
    }
  }
}

Endpoints rekordów

Metoda Ścieżka Opis
GET /noe/dbs/:db_id/records.json Lista rekordów
GET /noe/dbs/:db_id/records/:id.json Szczegóły rekordu
POST /noe/dbs/:db_id/records.json Utworzenie rekordu
PATCH /noe/dbs/:db_id/records/:id.json Aktualizacja rekordu
DELETE /noe/dbs/:db_id/records/:id.json Usunięcie rekordu

POST — Utworzenie rekordu

POST /noe/dbs/todo/records.json

{
  "record": {
    "data": {
      "title": "Zadanie 1",
      "done": 0
    }
  }
}

Publiczne metody (bez autoryzacji)

Metoda Ścieżka Opis
POST /noe/db/:db_code/list Lista rekordów
POST /noe/db/:db_code/get Pobranie rekordu
POST /noe/db/:db_code/create Tworzenie rekordu
POST /noe/db/:db_code/update Aktualizacja rekordu
POST /noe/db/:db_code/delete Usunięcie rekordu
POST /noe/db/:db_code/search Wyszukiwanie

Konfiguracja public_methods

{
  "list": { "scope_by": "user_ip" },
  "create": {
    "allowed_fields": ["title", "done"],
    "required_fields": ["title"],
    "default_values": { "done": 0 },
    "auto_fields": { "user_ip": "{ip}" }
  },
  "update": { "allowed_fields": ["title", "done"], "scope_by": "user_ip" },
  "delete": { "scope_by": "user_ip" }
}

Zmienne w auto_fields: {ip} — adres IP, {cookie_key} — token per przeglądarka (30 dni)