Content Types
Content types are the foundation of your content structure in Meshbase. They define the schema and fields for your data collections.
What are Content Types?
A content type is a blueprint that defines the structure of your content. Think of it as a database table schema or a class definition. Each content type contains:
- A unique name and identifier
- A collection of custom fields
- Validation rules and constraints
- Display and formatting options
Creating a Content Type
Step 1: Navigate to Content-Type Builder
From your project dashboard, click on "Content-Type Builder" in the sidebar navigation.
Step 2: Create New Collection Type
Click "Create new collection type" and provide a display name (e.g., "Blog Post", "Product", "Author").
Step 3: Add Fields
Add fields to your content type by selecting field types and configuring their properties.
Step 4: Save and Deploy
Save your content type. The API endpoints will be automatically generated and ready to use.
Example: Blog Post Content Type
Here's an example of a typical blog post content type structure:
{
"name": "Blog Post",
"apiId": "blog-post",
"fields": [
{
"name": "title",
"type": "text",
"required": true
},
{
"name": "slug",
"type": "text",
"unique": true
},
{
"name": "content",
"type": "richtext"
},
{
"name": "author",
"type": "relation",
"target": "author"
},
{
"name": "publishedAt",
"type": "datetime"
},
{
"name": "featured",
"type": "boolean",
"default": false
}
]
}Best Practices
- Use clear, descriptive names for your content types
- Plan your content structure before creating types
- Keep content types focused and single-purpose
- Use relations to connect related content
- Set appropriate validation rules for data integrity
- Consider SEO fields like slug and meta descriptions