Add fields
We will now add some fields to our Product
model for a product name
, price
and image
.
To add a field, select one of the field types from the right side of the schema editor.
List of available fields
#Create a name field
Select Single line text from the available types and set the Display name to Name
.
Configure field name
Then make sure to enable Make field required in the VALIDATIONS tab.
Set field as required
Once you're happy configuring this field, click the Add button.
Add field
#Create a price field
Let's now add another field, but using the Integer type. Select Number from the available types, and set the Display name to Price
.
Configure field name
Then make sure to enable Make field required in the VALIDATIONS tab.
Set field as required
Once you're happy configuring this field, click the Add button.
Add field
#Create an image field
We'll now add our final field, and for this we'll use the Asset model as a relation for multiple product photos.
The Asset
model is a special type of field that allows us to store images and other files.
Assets are a core feature in Hygraph, and the assets model is added to every new project by default.
Select Asset Picker from the available types and set the Display name to Image
. Make sure to also select Allow multiple values:
Configure asset field
Once you're happy configuring this field, click the Add button.
Add field
Now your Product
model should now look a little something like this:
Product model fields
#Explore system fields
Hygraph by default handles system fields for things such as the id
, createdAt
, publishedAt
, and more
.
You can see all of the system fields for your selected model by clicking on Show system fields:
Show system fields