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.
Create a name fieldAnchor
Select Single line text from the available types and set the Display name to Name
.
Then make sure to enable Make field required in the VALIDATIONS tab.
Once you're happy configuring this field, click the Add button.
Create a price fieldAnchor
Let's now add another field, but using the Integer type. Select Number from the available types, and set the Display name to Price
.
Then make sure to enable Make field required in the VALIDATIONS tab.
Once you're happy configuring this field, click the Add button.
Create an image fieldAnchor
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:
Once you're happy configuring this field, click the Add button.
Now your Product
model should now look a little something like this:
Explore system fieldsAnchor
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: