FastSchema

Concepts

View as MarkdownEdit on GitHub

This is a list of concepts that are important to understand when working with the website.

This is a list of concepts that are important to understand when working with the website.

Schema

A schema is a blueprint for the data that will be stored in the CMS. It defines the structure of the data, including the types of data that can be stored and the relationships between different types of data.

A Schema is a JSON object that includes the following fields:

  • name (*): The name of the schema. This is used to identify the schema in the CMS and must be unique.
  • namespace (*): The namespace of the schema. This is used to create database tables and API endpoints.
  • label_field (*): The field that will be used as the label for items in the CMS. This is typically a human-readable field like a title or name.
  • disable_timestamp: A boolean value that determines whether the schema should include timestamp fields like created_at and updated_at.
  • is_system_schema: A boolean value that determines whether the schema is a system schema. A System schema is a schema that come built-in with the CMS or a schema that was created from a Go struct. A system schema can only be extended and cannot be deleted.
  • db: The database configuration for the schema. Currently, it support adding indexes and unique constraints to the schema.
  • fields (*): An array of field objects that define the fields that will be stored for each item in the CMS.

Field

A field is a single piece of data that is stored for each item in the CMS. Fields can be of different types, such as text, number, date, or relationship. Each field has a name, type, and other properties that define how the data should be stored and displayed.

Resource

In FastSchema, a Resource is a component that processes user requests and returns responses. It functions similarly to a controller in the MVC pattern or a resolver in GraphQL.

Resources can be grouped, which is useful for organizing related endpoints. For example, you might group all user-related resources together.

Each Resource must have a handler, a function that processes the user request and returns the response.

When defining a Resource, you can specify the input data that it expects and the output data that it returns. This is useful for documenting the API and for validating the input and output data.

Client requests don't go directly to the Resource. Instead, they are routed by a resolver, which directs the request to the appropriate Resource. Currently, FastSchema uses a RestfulResolver, which routes requests based on the HTTP method and path. In the future, additional resolvers, such as a GraphQL resolver, may be introduced.

For more information, refer to the Resource Documentation.

On this page