Setup

To begin, we will create a new blank project (opens in a new tab) in your Keel Console. Once you deploy a schema, you will be able to access internal tools in the Operate section of the sidebar.

Operate section

Creating a schema

Before we use this section, let's create a schema with some models and fields.

The Product model

Let's first create a Product model for which we want to manage stock. We'll give it a name, an optional description and an optional image URL.

model Product {
    fields {
        name Text
        description Text?
        imageUrl Text?
    }
}

The StockItem model

Since we want to track how many products we have in stock, let's create a StockItem model with a quantity field and a one-to-many relationship to the Product (a product can have many stock items).

model Product {
    fields {
        name Text
        description Text?
        imageUrl Text?
        stock StockItem[]
    }
}
 
model StockItem {
    fields {
        product Product
        quantity Number
    }
}

The StockLocation model

And lastly, we want to know where the stock is located. Let's create a StockLocation with an identifiable name and a relationship to StockItem (a location can keep many items).

model Product {
    fields {
        name Text
        description Text?
        imageUrl Text?
        stock StockItem[]
    }
}
 
model StockItem {
    fields {
        product Product
        quantity Number
        location StockLocation
    }
}
 
model StockLocation {
    fields {
        name Text @unique
        items StockItem[]
    }
}

Putting it all together

Now, we have the complete schema that drives our stock management application:

schema.keel
model Product {
    fields {
        name Text
        description Text?
        imageUrl Text?
        stock StockItem[]
    }
}
 
model StockItem {
    fields {
        product Product
        quantity Number
        location StockLocation
    }
}
 
model StockLocation {
    fields {
        name Text @unique
        items StockItem[]
    }
}

Previewing internal tools

With this schema, we can now deploy our project and start using the internal tools in the Keel Console (opens in a new tab). If you navigate to All tools in the Console per the screenshot above, you see that, apart from the built-in Identity tools, we haven't created any custom tools yet. Tools are generated from actions that you define in your schema, so let's create some in the next section.