🏗️Building your first Schema (Part 1)
Your First Schema: Building a 'Blog Post' Type
Welcome to your first hands-on guide with CoreModels. In this tutorial, we'll walk you through building a simple Blog Post schema from scratch. You'll use the core concepts you've learned to create your first Type and its Elements.
If you'd rather follow a different script, you can jump to Module 2 of the Crash Course to build a different example.
Step 1: Log In / Create an account
Before we begin, you need to log in to your account.
Navigate to the go.coremodels.io login page.
Click "Login to CoreModels" and use your preferred google or microsoft account.
Step 2: Create a New Project
In CoreModels, a "model" is the same as a Project. It's the highest-level container for all your schema assets.
From the left pane, click on "New Model".
Give your Project a clear name, like "My First Blog Project", and click "Create".
You now have a clean project to work in.
Step 3: Create a New Space (optional)
Now you need a Space to house your new schema.
Inside your new Project, from the top left dropdown (next to the CoreModels logo) click on the "All Spaces" drop down and click on "Add".
Give your Space a clear name, like "My First Blog Schema", and click "Create".
You now a space to categorize your nodes in.
Step 4: Define Your First Type with its Elements
Next, you'll create a Type to serve as the blueprint for all your blog posts.
In the Types grid UI, click on the green plus icon, it will open the 'Create New Type' modal.
Name your Type Blog Post.
(optional) if you created a space, then you can select it.
Click on the drop down next to 'Create', and click on the first option 'Create and Add Elements'.
Name the first element as Title
Click 'Add and Close'
You have now created a type and its first element.
Note that the relation Blog Post → Title is called 'Domain Includes' Checkout the FAQ section for more information, What's the default relation when creating Types and Elements ?.
Step 5: Add the rest of the Elements
Now, let's add the rest of the fields that a blog post needs. These are the Elements that will hold your content.
Within the Blog Post Type you just created, expand the "Elements" column.
Click on the caret icon next to the plus button, and click on 'Create Element'
Create the following Elements:
Name: Summary
Name: Body
Your Blog Post Type now has a Title, a Summary, and a Body field.
Step 6: Add a Mixin for a Rule
Let's make sure every blog post has a title by adding a rule. First we need to create the mixin
Click on the hamburger menu (☰) under the CoreModels logo, to open up the features tray.
Click on 'Mixins' (scroll down the features tray if it doesn't show up) and click on the plus button.
Set the mixin name as 'Validation Rules Mixin'
Click 'Create and Add Elements'
Set the mixin element name as 'Required' and choose the data type as 'Boolean', click Add & Close
Now let's use the mixin for our Title field
In the 'Types Grid' on the far right, you'll find the sidebar tab, click on 'configuration', which will expand the configuration menu.
In the 'Elements Mixins' select the 'Validation Rules Mixin', and close the configuration by re-clicking on the sidebar.
The column 'Required' should show up in the Elements grid.
Click on the checkbox, for the Title field to mark the Title as required
You've just added a rule to your schema that will prevent any blog post from being saved without a title.
What's Next?
Congratulations! You've successfully created your first schema. In just a few minutes, you've used Spaces, Types, Elements, and Mixins to build a functional blueprint.
From here, you can continue to expand your schema by:
Adding a Taxonomy for Categories to organize your posts.
Creating a Component to display your blog posts on a web page.
Saving a sample record as an Exemplar for documentation.
Last updated