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.
Which to use
Section titled “Which to use”| Need | Use |
|---|---|
| Read or write a known entity | platform:entities + tableRef |
| Enumerate entities or fields generically | sql.schema() / platform:schema |
| Validate an incoming payload | platform:zod |