Schema

Each collection has one schema which describes the content of the collection. You can think of the schema as a header row in a spreadsheet. The schema is made up of field definitions.

Each field holds a value and can be thought of as a single cell in a spreadsheet. An item can have many fields, but a field can only belong to one item.

Each field definition describes the name and type (string, number, boolean, etc) of the field. It also specifies whether or not the field is a primary key, the order in the primary key if it is a primary key, and the default value for the field. The name of the field can be thought of as the column name in a spreadsheet. Primary keys act as identifiers for the items they belong to. If an item's field value is not specified, the default value from the field definition will be used.

For example, suppose you want to store the following snippet from a spreadsheet:

First NamePhone NumberOver 18
1Bob1234567890true
2Alice4567890123true
3Carol7891234560false

The schema would have three field definitions, one for each column. The first field definition's name would be "First Name". The type would be "string". The "First Name" field is not the primary key since the unique identifier in this case is the "Phone Number". The second field definition's name would be "Phone Number". The type would be "number". It is a primary key, because it is a unique value that can be used to identify each item. The third field definition's name is "Over 18" with a type of "boolean".

The schema endpoints are responsible for the creation, deletion, and updating of field definitions within a schema. A user can only modify field definitions if they have access to the data source.