https://discord.gg/botpress logo
Why does my schema not save
# 🤝help
e
I am trying to save this typescript code for a schema
Copy code
/**
 * ProductsTable schema definition for Botpress Table.
 * Exported both as a JSON schema constant that can be passed to
 * bp.tables.createTable() and as a TypeScript type for row objects.
 */

export const productsTableSchema = {
  type: "object",
  required: [
    "title",
    "brand",
    "description",
    "product_id",
    "image",
    "url",
    "price",
    "availability",
    "stock_status",
    "quantity",
    "epifania",
    "iliko",
    "color",
    "varos",
    "important",
    "apoxrosi",
    "specs"
  ],
  properties: {
    title: { type: "string", "x-zui": { index: 0, searchable: true } },
    brand: { type: "string", "x-zui": { index: 1, searchable: true } },
    description: { type: "string", "x-zui": { index: 2, searchable: true } },
    product_id: { type: "string", "x-zui": { index: 3 } },
    image: { type: "string", "x-zui": { index: 4 } },
    url: { type: "string", "x-zui": { index: 5 } },
    price: { type: "number", "x-zui": { index: 6 } },
    availability: { type: "string", "x-zui": { index: 7 } },
    stock_status: { type: "string", "x-zui": { index: 9 } },
    quantity: { type: "number", "x-zui": { index: 10 } },
    epifania: { type: "string", "x-zui": { index: 11 } },
    iliko: { type: "string", "x-zui": { index: 12 } },
    color: { type: "string", "x-zui": { index: 13 } },
    varos: { type: "string", "x-zui": { index: 14 } },
    important: { type: "string", "x-zui": { index: 15 } },
    apoxrosi: { type: "string", "x-zui": { index: 16 } },
    specs: {
      type: "array",
      items: { type: "string" },
      "x-zui": { index: 17, searchable: true }
    }
  },
  additionalProperties: true
} as const;
Copy code
// Derived TypeScript row type
export type ProductsTableRow = {
  title: string;
  brand: string;
  description: string;
  product_id: string;
  image: string;
  url: string;
  price: number;
  availability: string;
  custom_stock_status: string;
  stock_status: string;
  quantity: number;
  epifania: string;
  iliko: string;
  color: string;
  varos: string;
  important: string;
  apoxrosi: string;
  specs: string[];
};

// Example: registering the table inside a Botpress module/action
/*
import { bp } from '@botpress/sdk';

await bp.tables.createTable('ProductsTable', productsTableSchema);
*/
p
A schema is an object definition, you shouldn't have actual code in it. Here's the docs about this topic: https://botpress.com/docs/learn/reference/schemas#schemas Hope this helps!
e
In the github on the bigcommerce intergration, the schema has the same format as mine
2 Views