Přejít na hlavní obsah
POST
/
v1
/
schemas
const schema = await client.schemas.create({
  name: "Electronics Catalog",
  description: "Schema for consumer electronics",
  columns: [
    { key: "product_name", label: "Product Name", type: "text", required: true },
    { key: "price", label: "Price", type: "number" },
    { key: "brand", label: "Brand", type: "text" },
    { key: "category", label: "Category", type: "enum", enum_values: ["phones", "laptops", "tablets"] },
    { key: "image_url", label: "Image", type: "image" },
    { key: "specs", label: "Specifications", type: "json" },
  ],
});

console.log(schema.id);
{
  "id": "schema_abc123",
  "name": "Electronics Catalog",
  "description": "Schema for consumer electronics",
  "is_default": false,
  "columns": [
    { "key": "product_name", "label": "Product Name", "type": "text", "required": true },
    { "key": "price", "label": "Price", "type": "number" }
  ],
  "created_at": "2025-03-01T10:00:00.000Z",
  "updated_at": "2025-03-01T10:00:00.000Z"
}

Tělo požadavku

name
string
povinné
Název schématu.
description
string
Popis, k čemu se toto schéma používá.
is_default
boolean
výchozí:"false"
Zda by toto mělo být výchozí schéma.
columns
array
povinné
Pole definic sloupců. Nesmí být prázdné.

Odpověď

id
string
Jedinečný identifikátor schématu.
name
string
Název schématu.
description
string | null
Popis schématu.
is_default
boolean
Zda je toto výchozí schéma.
columns
array
Definice sloupců.
created_at
string
Časové razítko ISO 8601.
updated_at
string
Časové razítko ISO 8601.
const schema = await client.schemas.create({
  name: "Electronics Catalog",
  description: "Schema for consumer electronics",
  columns: [
    { key: "product_name", label: "Product Name", type: "text", required: true },
    { key: "price", label: "Price", type: "number" },
    { key: "brand", label: "Brand", type: "text" },
    { key: "category", label: "Category", type: "enum", enum_values: ["phones", "laptops", "tablets"] },
    { key: "image_url", label: "Image", type: "image" },
    { key: "specs", label: "Specifications", type: "json" },
  ],
});

console.log(schema.id);
{
  "id": "schema_abc123",
  "name": "Electronics Catalog",
  "description": "Schema for consumer electronics",
  "is_default": false,
  "columns": [
    { "key": "product_name", "label": "Product Name", "type": "text", "required": true },
    { "key": "price", "label": "Price", "type": "number" }
  ],
  "created_at": "2025-03-01T10:00:00.000Z",
  "updated_at": "2025-03-01T10:00:00.000Z"
}

Typy sloupců

TypPopis
textProstý textový řetězec.
numberČíselná hodnota (celé číslo nebo desetinné číslo).
urlPlatná URL adresa.
emailE-mailová adresa.
dateŘetězec s datem nebo datem a časem.
booleantrue nebo false.
richtextText formátovaný v HTML nebo markdownu.
enumJedna z předdefinované sady hodnot (viz enum_values).
tagsPole textových štítků.
imageJedna URL adresa obrázku.
imagesPole URL adres obrázků.
jsonLibovolný JSON objekt.