Skip to content

Schema

import { schema } from "platform:stdlib";

Where platform:entities gives compile-time types, schema answers questions at runtime — for code that must work against entities it was not written for.

Reach for it when building something generic: an export that adapts to any entity, an admin view listing fields, a validator driven by configuration.

const tables = await sql.schema();
for (const table of tables) {
console.log(table.name, table.columns.length);
}

For anything where the entity is known at author time, import the generated class instead — you get autocompletion and a compile error when a field disappears.

NeedUse
Read or write a known entityplatform:entities + tableRef
Enumerate entities or fields genericallysql.schema() / platform:schema
Validate an incoming payloadplatform:zod