Skip to content

17 · Schemas

Field Introspection

`Schema.fields()` returns the field names in declaration order, enabling generic rendering and migrations.

On this page

Schema.fields() returns an array of strings with the field names in the order they were declared. This is useful for generic serialization, table headers, dynamic editing interfaces, and migration scripts — any code that needs to enumerate a schema's shape at runtime without hardcoding names.

Iterates over User.fields() with a for loop and displays the total with fields.len().

02-fields-introspection.zolo
Playground
// Feature: schema introspection — `Schema.fields()` returns field names
// Syntax: `Name.fields()` — array of strings, in declaration order.
// When to use: serialization, table headers, generic UI rendering,
// migrations — anywhere you need to enumerate the shape at runtime.

schema User {
  name: str,
  age: int,
  active: bool,
}

let fields = User.fields()
for field in fields {
  print(field)
}

// expected:
//   name
//   age
//   active

print("count: {fields.len()}")
// expected: count: 3

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br