Find the name of each Field in a Table

The first step is to find the name for all the Fields of the employees Table.

In this section, you will learn the different ways to find the name of each Field:

  • Manually in Morph.
  • Manually in the Developer Mode.
  • Programmatically with Morph API.

Manually in Morph

In Morph, the name of the Field we are looking for is the Field Slug (as explained in Terminology).

To find the Field Slug of each Field in Morph:

  1. Select the database within which you created the employees Table.
  2. Click on the employees Table.

You should have a similar view to this:

View of the `employees` Table in the Dashboard of Morph

View of the employees Table in the Dashboard of Morph


There is currently no option to view the Field Slug of all the Fields of a Table at once. So you need to find the Field Slug of each Field, one Field at a time.

To find the Table Slug of a single Field:

  1. Click on the Heading of the Field.
  2. Select the Edit Field option.
  3. The Edit Field settings sidebar appears on the right side of your screen.
  4. You can find the Field Slug among these settings.

These steps are shown below taking the regional_office Field as example.


Example with the regional_office Field

Click on the Heading of the regional_office Field.

Click on the Heading of Field in the Dashboard. In this example, we click on the Heading of the `name`  Field.

Click on the Heading of Field in the Dashboard.


The regional_office is now selected. All the cells below the Heading of the regional_office Field are highlighted and a dropdown menu with a list of options appears.

List of options associated with the selected Field.

List of options associated with the selected Field.


Select the Edit Field option.

Select the Edit Field option

Select the Edit Field option


The Edit Field settings sidebar appears on the right side.

Edit Field settings.

Edit Field settings sidebar.


You can find the value of the Field Slug among the settings.

Field Slug

Find the Field Slug of a Field in the Edit Field settings sidebar.


If you repeat the same process for the other Fields, you will obtain the Field Slug for all the Fiels:

FieldField Slug
emp_idemp_id
namename
mgr_idmgr_id
regional_officeregional_office
statusstatus

Manually in the Developer Mode

In the Developer Mode, the name of the Field we are looking for is the name entry of property (as mentioned in Terminology).

To find the name of each Field in a Table in the Developer Mode:

  • Select the database within which you created the employees Table.
  • Click on the employees Table.
  • Click on the Structure button, on the top right corner of your screen.

These steps are shown below taking the regional_office Field as example.


Example with the regional_office Field

First:

  • Select the database within which you created the employees Table.
  • Click on the employees Table.

You should have a similar view than this:

View of the employees Table in the Developer Mode.

View of the employees Table in the Developer Mode of Morph.


Click on the Structure button.

Click on the `Structure` button.

Click on the Structure button in the Developer Mode of Morph.


In the Structure view, you can see the list of entries (or properties) which define Fields in a Table in Morph.

Each row in the Structure view is a Field with its properties.

📘

Content vs Structure

The Structure view of a Table focuses on displaying information about the Fields themselves. It shows Fields and their entries (or properties).

The Content view of a Table focuses on the actual data or Records. It shows Records and Fields.


List of entries (or properties) of the Fields.

List of entries (or properties) of Fields of a Table in the `Structure` view in the Developer Mode of Morph.

List of entries (or properties) of Fields of a Table in the Structure view in the Developer Mode of Morph.


The name of the regional_office Field can be found under the name entry or property.

Name of the regional_office Field in the Developer Mode of Morph.

Name of the regional_office Field in the Structure view in the Developer Mode of Morph.


You now have the name of the regional_office Field, it is:regional_office.

The names of all the other Fields are all under this name entry (or property):

name
emp_id
name
mgr_id
regional_office
status

Programmatically with Morph API

To programmatically obtain the names of each Field in a Table in Morph, make a request to the Get List of Fields endpoint in Morph API.

Let's build the API request to the Get List of Fields endpoint for the employees Table.


Build the request

To build the request, you will need the following parameters.

Headers:

  • authorization header: x-api-key: {YOUR_API_KEY}
  • client-type: widget
  • Content-Type: application/json

ℹ️

How to get my API Key?

Head to Create an API Key.

Path parameters:

  • teamSlug
  • databaseId
  • tableSlug

ℹ️

Where can I find my teamSlug, databaseId and tableSlug?

Go to How to find teamSlug, databaseId and tableSlug.


Make the API request

cURL

To make the request directly using cURL:

  • Open a Terminal window.
  • Replace the following placeholders in the cURL template below with your own values.
    • In the URL:
      • {YOUR_TEAM_SLUG}
      • {YOUR_DATABASE_ID}
      • {YOUR_TABLE_SLUG}
    • In the headers:
      • {YOUR_API_KEY} for the x-api-key
  • Run the command in your Terminal.

Replace the placeholders with your own values:

curl --X POST "https://{YOUR_TEAM_SLUG}.api.morphdb.io/v0/{YOUR_DATABASE_ID}/simple-field/{YOUR_TABLE_SLUG}" \
--header "Content-Type: application/json" \
--header "client-type: widget" \
--header "x-api-key: {YOUR_API_KEY}"

Example with mock values:

curl --X POST "https://42d54rt5-d389-845a-6lkq-34z563gtu872.api.morphdb.io/v0/dw5g1h89-2637-253k-452b-7803j4x7e3vi/simple-field/employee_csv_demo" \
--header "Content-Type: application/json" \
--header "client-type: widget" \
--header "x-api-key: ms5sCDEOVNuIw92MNA3qLKih4xzY25D9PQY6D7Az2"

Postman

Coming soon.


Response

The Get List of Fields endpoint will return a List of Fields Response object, which is an array of Simple Field object.

In the example of the employees Table, the response from Morph API is:

{
  "fields": [
    {
      "name": "id",
      "type": "autoNumber",
      "default": "nextval('employee_csv_id_seq'::regclass)",
      "nullable": false,
      "comment": "",
      "originalTableSlug": "employee_csv",
      "primary": true
    },
    {
      "name": "emp_id",
      "displayName": "emp_id",
      "type": "number",
      "default": null,
      "nullable": false,
      "comment": "emp_id",
      "originalTableSlug": "employee_csv",
      "primary": false
    },
    {
      "name": "name",
      "displayName": "name",
      "type": "shortText",
      "default": null,
      "nullable": false,
      "comment": "name",
      "originalTableSlug": "employee_csv",
      "primary": false
    },
    {
      "name": "mgr_id",
      "displayName": "mgr_id",
      "type": "number",
      "default": null,
      "nullable": false,
      "comment": "mgr_id",
      "originalTableSlug": "employee_csv",
      "primary": false
    },
    {
      "name": "regional_office",
      "displayName": "Regional_Office",
      "type": "singleSelect",
      "default": null,
      "nullable": false,
      "comment": "Regional_Office",
      "members": [
        "Central",
        "East",
        "West",
        "US"
      ],
      "originalTableSlug": "employee_csv",
      "primary": false
    },
    {
      "name": "status",
      "displayName": "Status",
      "type": "singleSelect",
      "default": null,
      "nullable": false,
      "comment": "Status",
      "members": [
        "Current",
        "Former"
      ],
      "originalTableSlug": "employee_csv",
      "primary": false
    }
  ]
}

You can find the name of each Field by extracting the value of name property of each Field object from the response.

Ignore the first object which related to the id in your Table in Morph.

{
  "name": "id",
  "type": "autoNumber",
  "default": "nextval('employee_csv_id_seq'::regclass)",
  "nullable": false,
  "comment": "",
  "originalTableSlug": "employee_csv",
  "primary": true
}
{
  "fields": [
    // IGNORE THE FIRST OBJECT
    {
     // "name": "id",
     // "type": "autoNumber",
     // "default": "nextval('employee_csv_id_seq'::regclass)",
     // "nullable": false,
     // "comment": "",
     // "originalTableSlug": "employee_csv",
     // "primary": true
    },
    {
      "name": "emp_id",
     // "displayName": "emp_id",
     // "type": "number",
     // "default": null,
     // "nullable": false,
     // "comment": "emp_id",
     // "originalTableSlug": "employee_csv",
     // "primary": false
    },
    {
      "name": "name",
     // "displayName": "name",
     // "type": "shortText",
     // "default": null,
     // "nullable": false,
     // "comment": "name",
     // "originalTableSlug": "employee_csv",
     // "primary": false
    },
    {
      "name": "mgr_id",
     // "displayName": "mgr_id",
     // "type": "number",
     // "default": null,
     // "nullable": false,
     // "comment": "mgr_id",
     // "originalTableSlug": "employee_csv",
     // "primary": false
    },
    {
      "name": "regional_office",
     // "displayName": "Regional_Office",
     // "type": "singleSelect",
     // "default": null,
     // "nullable": false,
     // "comment": "Regional_Office",
     // "members": [
       // "Central",
       // "East",
       // "West",
       // "US"
     // ],
     // "originalTableSlug": "employee_csv",
     // "primary": false
    },
    {
      "name": "status",
     // "displayName": "Status",
     // "type": "singleSelect",
     // "default": null,
     // "nullable": false,
     // "comment": "Status",
     // "members": [
       // "Current",
       // "Former"
     // ],
     // "originalTableSlug": "employee_csv",
     // "primary": false
    }
  ]
}

You found list the name of each Field:

  • emp_id
  • name
  • mgr_id
  • regional_office
  • status

We have just seen how to find programmatically the name of each Field of the employees.


Recap: finding the name of each Field

You have completed the first part.

You have learned how to find the name of each Field, with 3 different methods:

  • Manually in Morph.
  • Manually in the Developer Mode.
  • Programmatically with Morph API.

You now have the names of all the Fields of the employees Table:

  • emp_id
  • name
  • mgr_id
  • regional_office
  • status

You can now define the key properties in the objects of the values array.

In the next section, we will use these names to build the values array in the body parameter of the Create Record endpoint.